MCPcopy
hub / github.com/danielgtaylor/huma / marshalJSON

Function marshalJSON

openapi.go:77–96  ·  view source on GitHub ↗

marshalJSON marshals a list of fields and their values into JSON. It supports inlined extensions.

(fields []jsonFieldInfo, extensions map[string]any)

Source from the content-addressed store, hash-verified

75// marshalJSON marshals a list of fields and their values into JSON. It supports
76// inlined extensions.
77func marshalJSON(fields []jsonFieldInfo, extensions map[string]any) ([]byte, error) {
78 value := make(map[string]any, len(extensions)+len(fields))
79
80 for _, v := range fields {
81 if v.omit == omitNil && isNilValue(v.value) {
82 continue
83 }
84 if v.omit == omitEmpty {
85 if isEmptyValue(reflect.ValueOf(v.value)) {
86 continue
87 }
88 }
89
90 value[v.name] = v.value
91 }
92
93 maps.Copy(value, extensions)
94
95 return json.Marshal(value)
96}
97
98// Contact information to get support for the API.
99//

Callers 15

MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85

Calls 3

isNilValueFunction · 0.85
isEmptyValueFunction · 0.85
MarshalMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…