I am trying to get the departments id where location is USA in the following JSON
{
"datapoints": [{
"id": "default.1",
"definedBy": "default/0.1",
"featureValues": {
"bui.displayname": "Health status",
"bui.visibility": "normal",
"default.access": "r",
"default.basetype": "text",
"default.description": "Aggregated health status",
"default.format": "text/plain",
"default.name": "health_status",
"default.restriction": "re:(OK|WARN|ERROR|UNKNOWN)",
"name" : [
{
"brand": "apple" ,
"company": [
{
"location": "UAS"
}
],
"manager": "stev"
}
]
}
}, {
"id": "kdl.240",
"definedBy": "kdl/0.9",
"featureValues": {
"bui.displayname": "Delta K",
"bui.visibility": "normal",
"default.access": "rw",
"default.basetype": "real",
"default.description": "Delta K",
"default.name": "Delta_K",
"default.privacy": "false",
"default.restriction": "b32",
"name" : [
{
"brand": "apple" ,
"company": [
{
"location": "canada"
}
],
"manager": "abc"
}
]
}
}
]
}
I tried
$.datapoints[?(@.featureValues.name[0].company[*].location == 'USA')].id
but this gives me not matched. I perform this test on https://jsonpath.com/
0
index for company too.$.datapoints[?(@.featureValues.name[0].company[0].location == 'USA')].id
– PeipeifferUAS
as location value instead ofUSA
– Peipeiffer