I am working on JSONPath where I need to fetch a value for a particular country below is the given 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": []
}
For the given JSON I need to fetch locationControlId
for a particular country.
I have tried
$.internationalControlDetails.[?(@.country == 'Canada')].locationControlId
But it is not working.
I am expecting to fetch locationControlId
for a particular country like Canada, United States