【发布时间】:2022-01-22 06:27:52
【问题描述】:
鉴于 Goessner 示例 JSON:
{
"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": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"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
}
}
}
我可以使用以下查询获得一本书的最高价格:
$.max($.store.book[*].price)).
回复:22.99。
如果我查询这个价格:$.store.book[?(@.price ==22.99)]
回复:
[
{
"category" : "fiction",
"author" : "J. R. R. Tolkien",
"title" : "The Lord of the Rings",
"isbn" : "0-395-19395-8",
"price" : 22.99
}
]
但尝试将 max 表达式内联到查询中只会出现语法错误:
$.store.book[?(@.price ==$.max($.store.book[*].price)))]
这可以在单个 JSONPath 查询中实现吗?
【问题讨论】:
标签: jsonpath