Given the following JSON:
[
{
"json": {
"buildInfo": [
{
"first": "James",
"last": "d"
},
{
"first": "James2",
"last": "d2"
}
]
},
"status": 200
},
{
"json": {
"buildInfo": [
{
"first": "Jacob",
"last": "e"
},
{
"first": "Jacob2",
"last": "e2"
}
]
},
"status": 200
}
]
I am trying to query the inner list key json.buildInfo."last" for a value to then extract an number of key value ie json.buildInfo.*."first". HOwever I am struggling to get this to work.
I can find the data using a flattening operator...
[*].json.build[].last[contains(@,`d`)]
...but I cannot work out how to perform a query on this that then allows me to obtain extra information list "first" key. On a json with no inner list on buildInfo, I can do something like
[?json.buildInfo.last==`d`].json.buildInfo.first
The switch to list of buildInfo items is proving challenging.
Can someone provide me an guidance here?
Thanks
OK this works - but not sure I know why...
[?json.buildInfo[?contains(last,'d2')]].json.build_info[]|[?last=='d'].first