buger / jsonparser

One of the fastest alternative JSON parser for Go that does not require schema
MIT License
5.4k stars 434 forks source link

use jsonpath as key #234

Open bartsimp opened 2 years ago

bartsimp commented 2 years ago

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

buger commented 2 years ago

What about adding helper like this?

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

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