我在 jsonpath 上工作,我需要为下面的特定国家/地区获取值是给定的 json。
{
"homeCountry": "USA",
"internationalControlDetails": [
{
"address": {
"city": null,
"country": "Canada",
"county": null,
"state": null,
"zipCode": null
},
"dateRange": {
"endDate": null,
"startDate": null
},
"isHomeCountry": false,
"regionId": null,
"locationControlId": 649289
},
{
"address": {
"city": null,
"country": "United States",
"county": null,
"state": null,
"zipCode": null
},
"dateRange": {
"endDate": null,
"startDate": null
},
"isHomeCountry": true,
"regionId": null,
"locationControlId": 837251
}
],
"locationShieldState": "DISABLED",
"regionControlDetails": []
}
我试过 $.internationalControlDetails.[?(@.country=='Canada')].locationControlId 但它不起作用。
我期待获取特定国家(如加拿大、美国)的 locationControlId
你的路径应该是
$.internationalControlDetails.[?(@.address.country=='Canada')].locationControlId
注意本地路径中的
address
其他一切看起来都不错。