MCPcopy Create free account
hub / github.com/buger/jsonparser / ArrayEachWildcard

Function ArrayEachWildcard

wildcard.go:72–83  ·  view source on GitHub ↗

ArrayEachWildcard iterates over an array addressed by keys. A terminal [*] component is accepted as an explicit request for all elements; without it, the function behaves like ArrayEachErr. SYS-REQ-113

(data []byte, cb func(idx int, value []byte, vt ValueType, offset int, err error) error, keys ...string)

Source from the content-addressed store, hash-verified

70// the function behaves like ArrayEachErr.
71// SYS-REQ-113
72func ArrayEachWildcard(data []byte, cb func(idx int, value []byte, vt ValueType, offset int, err error) error, keys ...string) (int, error) {
73 if len(keys) > 0 && keys[len(keys)-1] == wildcardPathComponent {
74 keys = keys[:len(keys)-1]
75 }
76
77 index := 0
78 return ArrayEachErr(data, func(value []byte, valueType ValueType, offset int, err error) error {
79 current := index
80 index++
81 return cb(current, value, valueType, offset, err)
82 }, keys...)
83}
84
85// SetWildcard applies Set to every concrete path matched by [*]. Wildcards
86// may appear at any array position and may be repeated. If a wildcard matches

Callers 3

TestArrayEachWildcardFunction · 0.85
EachArrayWildcardFunction · 0.85

Calls 1

ArrayEachErrFunction · 0.85

Tested by 2

TestArrayEachWildcardFunction · 0.68