MCPcopy
hub / github.com/wavetermdev/waveterm / getJSONName

Function getJSONName

pkg/util/utilfn/marshal.go:126–132  ·  view source on GitHub ↗

getJSONName returns the field name to use for JSON mapping

(field reflect.StructField)

Source from the content-addressed store, hash-verified

124
125// getJSONName returns the field name to use for JSON mapping
126func getJSONName(field reflect.StructField) string {
127 tag := field.Tag.Get("json")
128 if tag == "" || tag == "-" {
129 return field.Name
130 }
131 return strings.Split(tag, ",")[0]
132}
133
134// setValue attempts to set a reflect.Value with a given interface{} value
135func setValue(field reflect.Value, value any) error {

Callers 2

MapToStructFunction · 0.70
StructToMapFunction · 0.70

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected