MCPcopy
hub / github.com/tidwall/gjson / Paths

Method Paths

gjson.go:3434–3447  ·  view source on GitHub ↗

Paths returns the original GJSON paths for a Result where the Result came from a simple query path that returns an array, like: gjson.Get(json, "friends.#.first") The returned value will be in the form of a JSON array: ["friends.0.first","friends.1.first","friends.2.first"] The param 'json' mu

(json string)

Source from the content-addressed store, hash-verified

3432// when the Result came from a path that contained a multipath, modifier,
3433// or a nested query.
3434func (t Result) Paths(json string) []string {
3435 if t.Indexes == nil {
3436 return nil
3437 }
3438 paths := make([]string, 0, len(t.Indexes))
3439 t.ForEach(func(_, value Result) bool {
3440 paths = append(paths, value.Path(json))
3441 return true
3442 })
3443 if len(paths) != len(t.Indexes) {
3444 return nil
3445 }
3446 return paths
3447}
3448
3449// Path returns the original GJSON path for a Result where the Result came
3450// from a simple path that returns a single value, like:

Callers 1

TestQueryGetPathFunction · 0.80

Calls 2

ForEachMethod · 0.95
PathMethod · 0.80

Tested by 1

TestQueryGetPathFunction · 0.64