jsonparser icon indicating copy to clipboard operation
jsonparser copied to clipboard

use jsonpath as key

Open bartsimp opened this issue 3 years ago • 2 comments

Hello,

it's possible to use a jsonpath notation to perform the lookup?

jsonparser.Get(data, "$.person.name.fullName")

equivalent to:

jsonparser.Get(data, "person", "name", "fullName")

regards

bartsimp avatar Aug 06 '21 09:08 bartsimp

What about adding helper like this?

func JSONPath(path) {
  return strings.Split(strings.TrimPrefix(path, "$."), ".")
}
....
jsonparser.Get(data, JSONPath("$.person.name.fullName")...)

buger avatar Aug 06 '21 15:08 buger

Is there recent development to support jsonpath ? I wonder if I can use @.length to access array length.

tedyu avatar Dec 27 '23 08:12 tedyu