如何使用JSONPath过滤带有嵌套数组的JSON主体



这是我一直在使用的JSON路径:

$..products[?(@.category == 'merchant_cards' && @.countries[0].abbr == 'US' && @.skus[0].min < '25')]

但是,我收到一个错误end of input expected at 1:12

以下是正文摘录:

[
{
"id": "ACGZXBCIGX8Y",
"name": "Overstock.com",
"currency_codes": [
"USD"
],
"skus": [
{
"min": 5,
"max": 500
}
],
"countries": [
{
"abbr": "US"
}
],
"category": "merchant_cards",
"disclosure": "",
"description": "",
"images": [
{
"src": "https://giftrocket-s3.imgix.net/Brands/US/Overstock/Digital/Overstock.png",
"type": "card"
}
]
},

我希望能够过滤一些嵌套列表,这似乎是造成问题的原因。

例如,我只想要那些在美国的。countries是一个列表,它有一个abbr节点,可以有多个值。

当我完成json数组时,它起作用:

$[?(@.category == 'merchant_cards' && @.countries[0].abbr == 'US' && @.skus[0].min < 25)]

我还将最小限制更改为整数

试穿一下https://jsonpath.com/

最新更新