Find a key wherever it is
ric79 opened this issue · 3 comments
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
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]
@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.
@ric79 We want to propose this feature to JMESPath and will include this in the next iteration for JMESPath Community.