有了下面的书店,我想找出所有符合类别‘小说’and‘奇幻’的书.
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "adventure",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fantasy",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
我找到了这个示例[?(@.size in ['S', ‘M'])]
here,它看起来与我想要的一模一样,但我无法让它在https://jsonpath.com上工作
这就是我try 过的:
$.store.book.[?(@.category in ['fiction','fantasy'])]
仅查找单个标准值的效果为https://jsonpath.com:
$.store.book.[?(@.category == 'fiction')]
谢谢你给我的提示,让我知道正确的方向.