flitbit / json-ptr

A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.
MIT License
91 stars 28 forks source link

filtering query by index returns undefined result #12

Closed klokie closed 6 years ago

klokie commented 7 years ago

Hi, thanks for this project and for json-path! I have to admit I'm not 100% clear on the difference/relation between the two, so if I've reported this issue in the wrong queue, please let me know ;)

I've got a number of queries with paths like #/parent_array_field[*]/child_array_field/0, meaning that I want to fetch the first element from the child array that may be found in any of the parent fields (common in GraphQL result sets). However, if I add an additional array filter on the end to try to filter the entire result set, à la "#/parent_array_field[*]/child_array_field/0[0]", the resolution returns undefined. Is this a bug, or am I doing it wrong?

Thanks again!

flitbit commented 6 years ago

Well I know I'm late to the party, and the question is better suited for json-path, but try #/parent_array_field[*]/child_array_field/0/0... essentially, if there is a JSON Pointer way to do it, prefer it over the json-path way because it performs better.

That being said, your syntax should also work.

If it is still an issue please post to the json-path project.