MCPcopy Create free account
hub / github.com/go-openapi/jsonpointer / GetJSONNames

Method GetJSONNames

jsonname/name_provider.go:84–98  ·  view source on GitHub ↗

GetJSONNames gets all the json property names for a type.

(subject any)

Source from the content-addressed store, hash-verified

82
83// GetJSONNames gets all the json property names for a type.
84func (n *NameProvider) GetJSONNames(subject any) []string {
85 n.lock.Lock()
86 defer n.lock.Unlock()
87 tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
88 names, ok := n.index[tpe]
89 if !ok {
90 names = n.makeNameIndex(tpe)
91 }
92
93 res := make([]string, 0, len(names.jsonNames))
94 for k := range names.jsonNames {
95 res = append(res, k)
96 }
97 return res
98}
99
100// GetJSONName gets the json name for a go property name.
101func (n *NameProvider) GetJSONName(subject any, name string) (string, bool) {

Callers 1

TestNameProviderFunction · 0.95

Implementers 3

stubNameProvideroptions_test.go
NameProviderjsonname/name_provider.go
GoNameProviderjsonname/go_name_provider.go

Calls 1

makeNameIndexMethod · 0.95

Tested by 1

TestNameProviderFunction · 0.76