New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searching for literal * keys return all when * unavailable #77
Comments
*
keys return all when *
unavailable
Actually this also applies in reverse: JSONPath({json: {'*': 'star', 'rest': 'rest', 'foo': 'bar'}, path: "$.*"})
//=> [ 'star' ] |
…scaped (breaking change); Refactoring (group similar together)
…scaped (breaking change); Refactoring (group similar together)
I've added a commit to If this will end up as a problem, I can revert, but I think this behavior makes the most sense and is the safest. |
Thanks for the quick response! This works in the flat structures, but leads to some unexpected results with more complex nested structures: let json = {'*': 'star', 'foo': 'bar', 'sibling': { child: 'sibling child', '*': 'sibling star'}}
// earlier tests work as expected
JSONPath({ json, path: "$[foo,`*]" })
// => [ 'bar', 'star' ]
// sibling subqueries ignore `*
JSONPath({ json, path: "$[`*,sibling[child,`*]]" })
// => [ 'sibling child', 'sibling star' ]
// ordering of subqueries queries changes results
JSONPath({ json, path: "$[sibling[child,`*],`*]" })
// => [ 'sibling child', 'sibling star', 'sibling star' ] I'm also curious as to why you chose |
The current parsing is regex based. I think we'd need to move to something more robust to deal properly with the nesting. I also don't have a lot of time to work on this project atm. Feel free to submit any PRs to handle though (along with your test cases). As far as the backtick, I just used that (along the lines of templates, etc.) because I hadn't provided support for escaping of individual characters but rather for the whole sequence. |
ah, I see - the |
FYI, the feature is included with v0.16.0, now released. |
Searching for a literal
*
with$['*']
yields the following unexpected behavior:It's possible to work around this with
$[?(@property === '*')]
, but this isn't usable in more complex queries, such as$[?(@property === '*'), rest]
The text was updated successfully, but these errors were encountered: