I would like to extract an element based on a condition inside a nested JSON response. Using the widely searched example below, I would like to extract the storeid of all books authored by "Foo Bar":
{
"store": {
"storeId": 1
"book": [
{
"category": "reference",
"author": [
{
"Nigel Rees",
"Foo Bar"
}
],
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": [
{
"Evelyn Waugh"
}
],
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
I have tried using expressions like: $.store[?(@..author=='Foo Bar')].storeId
I have also tried to see if there are any store returned at all using: $.store[*].book[?(@.author=='Foo Bar')]
But no result returned... Please help. Thanks!