【发布时间】:2020-09-01 23:50:40
【问题描述】:
我想根据嵌套 JSON 响应中的条件提取元素。使用下面广泛搜索的示例,我想提取由“Foo Bar”撰写的所有书籍的 storeid:
{
"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
}
我尝试过使用如下表达式: $.store[?(@..author=='Foo Bar')].storeId
我还尝试查看是否有任何商店使用: $.store[*].book[?(@.author=='Foo Bar')]
但是没有返回结果...请帮忙。谢谢!
【问题讨论】: