Documentation ¶
Index ¶
- type Enter
- func (js Enter) FromJSON(j string, o any) *any
- func (js Enter) GetValue(src string, path string) gjson.Result
- func (js Enter) GetValues(src string, path ...string) []gjson.Result
- func (js Enter) ToJson(obj interface{}) string
- func (js Enter) ToObjB(src []byte, obj interface{}) bool
- func (js Enter) ToObjI(src interface{}, obj interface{}) bool
- func (js Enter) ToObjS(src string, obj interface{}) bool
- func (js Enter) Valid(src string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Enter ¶
type Enter struct{}
func (Enter) GetValue ¶
GetValue searches json for the specified path. A path is in dot syntax, such as "name.last" or "age". When the value is found it's returned immediately.
A path is a series of keys separated by a dot. A key may contain special wildcard characters '*' and '?'. To access an array value use the index as the key. To get the number of elements in an array or to access a child path, use the '#' character. The dot and wildcard character can be escaped with '\'.
{ "name": {"first": "Tom", "last": "Anderson"}, "age":37, "children": ["Sara","Alex","Jack"], "friends": [ {"first": "James", "last": "Murphy"}, {"first": "Roger", "last": "Craig"} ] } "name.last" >> "Anderson" "age" >> 37 "children" >> ["Sara","Alex","Jack"] "children.#" >> 3 "children.1" >> "Alex" "child*.2" >> "Jack" "c?ildren.0" >> "Sara" "friends.#.first" >> ["James","Roger"]
This function expects that the json is well-formed, and does not validate. Invalid json will not panic, but it may return back unexpected results. If you are consuming JSON from an unpredictable source then you may want to use the Valid function first.
func (Enter) GetValues ¶
GetValues searches json for the multiple paths. The return value is a Result array where the number of items will be equal to the number of input paths.