Given the following JSON:
<code>{
"id": "0001",
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" }
]
}
</code>
<code>{
"id": "0001",
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" }
]
}
</code>
{
"id": "0001",
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" }
]
}
I would like to return true or equivalent if id 5001 does not exist in the array. Should also return true if the array is empty.
<code>$.topping[?((!(@.id == '5001') && ($.topping empty false)) || ($.topping empty true))]
</code>
<code>$.topping[?((!(@.id == '5001') && ($.topping empty false)) || ($.topping empty true))]
</code>
$.topping[?((!(@.id == '5001') && ($.topping empty false)) || ($.topping empty true))]
Returns with the data excluded. How can I tell if the filter applied?
Tested on https://www.javainuse.com/jsonpath
New contributor
Jayson Ramirez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.