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

Find a key wherever it is #272

Open
ric79 opened this issue Feb 9, 2022 · 3 comments
Open

Find a key wherever it is #272

ric79 opened this issue Feb 9, 2022 · 3 comments

Comments

@ric79
Copy link

ric79 commented Feb 9, 2022

Hello, is there a syntax in order to specify to look for a key in the whole data structure?

For example in JSONPath I can execute
$.sections[*]..item

The double dots indicate to search 'item' at every nested level after 'sections'

Is it possible also in jmespath?
Riccardo

@Minitour
Copy link

Minitour commented Jul 7, 2022

The * is what you are looking for. Assuming your object looks like this:

{
   "A": 1,
   "B": 2,
   "C": 3
}

You can simply use

@.* 

Which will result in

[1, 2, 3]

@springcomp
Copy link

springcomp commented Aug 9, 2022

@ric79 unfortunately what you want to achieve is not possible using JMESPath. You have to know the input structure to query specific portions of the input.

As currently specified, I’m not sure what would be a valid use case for such a feature. 🤔

However, with the introduction of the let() function coming to JMESPath community, I definitely can see a use case where you would search for some property recursively, store that in the current lexical context and use it for downstream expressions.

@springcomp
Copy link

@ric79 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants