I'm recieving multiple Events (following JSON) from a Queue and I don't want to take all of them, only the events with Sales Organization="180C":
{
"eventID": "string",
"eventType": "string",
"eventDate": "2024-03-15T18:21:24Z",
"source": "string",
"dataKey": "string",
"dataChange": {
"KEY": []
},
"dataScope": {
"dataObject": "string",
"KEY": [
{
"scope": "scope1",
"value": "scope2"
},
{
"scope": "scope2",
"value": "scope3"
},
{
"scope": "Sales Organization",
"value": "190B"
}
]
}
}
I used this filter but not working as intended :
$.[?($.dataScope.KEY[?(@.scope=='Sales Organization' && @.value=='190B')])]
When I try this filter alone : $.dataScope.KEY[?(@.scope=='Sales Organization' && @.value=='190B')] I get an empty array [] when the condition is not satisfied.
UDPATE:
[], don't use a dot.. So you'll start with$[, not$.[.@to start paths in filters.@indicates the current item root.$indicates the document root.So, instead of starting your path with
$.[?($.dataScope, start with$[?(@.dataScope.Previous answer, not knowing that the posted event was one in an array of events.
What is this for? Why the extra bit on the front?
You have the right path, it's just buried in this extra filter for some reason. Just use
(also,
$.[]with a dot is invalid. Omit the dot when using brackets:$[].)You can test this at https://json-everything.net/json-path, which implements the new IETF JSON Path specification RFC 9535.
EDIT
The output for this (from my playground) is