I have a JSON file in the format below.
{
"queryResponse":[
{
"id":"1",
"name":"Parent1",
"childList":[
{
"id":"11",
"type":"A"
},
{
"id":"12",
"type":"B"
}
]
},
{
"id":"2",
"name":"Parent2",
"childList":[
{
"id":"21",
"type":"B"
},
{
"id":"22",
"type":"C"
}
]
}
]
}
Using jayway JsonPath, how do I get all parent nodes that have child nodes of type "B"?
These filter expressions return an empty array:
- wild card in the index, for example $ .queryResponse [? (@. childList [*]. type == 'B')]
- deep scan operator in the filter field, for example $ .queryResponse [? (@. childList..type == 'B')]
The only filter expression that comes closest to what I need is an index with an array index for ex: $ .queryResponse [? (@. childList [0] .type == 'A')]
source
share