Skip to content
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

Non-rooted expressions support #110

Open
davidkhess opened this issue Aug 15, 2016 · 10 comments
Open

Non-rooted expressions support #110

davidkhess opened this issue Aug 15, 2016 · 10 comments

Comments

@davidkhess
Copy link

davidkhess commented Aug 15, 2016

I may just be missing it, but it doesn't seem to be possible to do the equivalent of // in XPath. I.e. find the desired expression anywhere in the supplied JSON versus from the root of it. If not, can that be made a feature request?

The use case is when you are trying to find subsets of JSON in a document whose overall structure you cannot predict in advance.

@jamesls
Copy link
Member

jamesls commented Aug 17, 2016

Not currently possible, but something I think would be useful.

@davidkhess
Copy link
Author

It's pretty necessary if you are working with JSON with an unknown schema but need to recognize subsets within it. I find it crops up when using JSON for metadata.

I'm not sure how many folks need this – but it's a deal breaker for that kind of situation.

@gholder
Copy link

gholder commented Sep 22, 2016

Agreeing with DavidHess.
Your documentation and the project look great, but it's necessary to do the non-rooted searches.

@EricLanduyt
Copy link

EricLanduyt commented Oct 11, 2016

I agree too, non-rooted expressions is the only real thing missing in JMESPath, something like a.**.b would be so nice.

@caphrim007
Copy link

@jamesls would you propose a syntax for this to the JMESPath specification? even if it's not yet implemented, a proposed syntax would allow someone to produce a PR that does implement it for your review

@sauron918
Copy link

It's really missing.. Is there any changes in this direction since 2016?

@ogaida
Copy link

ogaida commented Mar 29, 2020

for the meantime, here is a bash function i use to search values in json with jq:

function jsonValueSearch (){
    searchString=$1;
    jq -r 'paths as $path | select(getpath($path) == "'"$searchString"'") | $path | ".\(map("[\(tojson)]") | join(""))"'
}

@tdrl
Copy link

tdrl commented May 11, 2021

Upvote!

@chipsenkbeil
Copy link

chipsenkbeil commented Jun 16, 2021

@jamesls what are your thoughts on adopting the same recursive descent syntax as JSONPath and E4X, where .. is used to signify the descent operator. Supporting its use both at the top level (to traverse the entire JSON object) or in some portion of a definition (to traverse only the subtree).

I was going to switch from a Rust JSONPath library to the jmespath.rs library (after getting it modernized), but I need recursive descent for my use case. I serialize a lot of Rust data structures representing the vimwiki markup language into JSON. If I wanted to look up a tag, snippet of text, etc. I only know the subtree within JSON and not necessarily the full path.

image

@springcomp
Copy link

@chipsenkbeil We want to propose this feature to JMESPath and will include this in the next iteration for JMESPath Community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants