GetJSONNames gets all the json property names for a type.
(subject any)
| 82 | |
| 83 | // GetJSONNames gets all the json property names for a type. |
| 84 | func (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. |
| 101 | func (n *NameProvider) GetJSONName(subject any, name string) (string, bool) { |