PaesslerAG/gval

Result line/column information

danielgtaylor opened this issue · 1 comments

Is it possible to get source location information for the returned results? I'm primarily interested in a JSON Path use-case where I can tell where in the original document the results of the query came from, e.g. a query like $..parameters[?@.in == "query"] gives me a bunch of parameter objects and I'd like to know the line/col of the start of each parameter in the input file bytes. Is this something that is currently possible or something you would support in this library?

Yes it's not part of gval but part of jsonpath.

Take a look at https://godoc.org/github.com/PaesslerAG/jsonpath#PlaceholderExtension

It doesn't have an example yet.
Jsonpath will return a string to interface{} map if you wrap the path like this { #0 : $..parameters[?@.in == "query"] }
for this query
#0 contains the keys from ..
#1 contains the key from [?@.in == "query"]