You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...you wouldn't want the parent selector (^), as that would be looking above root (since that filter is on an object, and that object happens to be root.
But even without the parent selector, the expression still doesn't match.
I think the problematic aspect here is that filters apply to children, and there is thus no apparent way to use the object-selectors in a way that matches root (though as per your first example, and as per #118, one can use property selectors along with the parent selector to match root because property selectors are looking at children not at the containing parent object).
Note that this gets the object (albeit in an array):
That works because the object is no longer at root, and the comparison is on the children.
So I think the real issue here is that we need a type of filter which checks the targeted item directly rather than its children (or at least so that we might allow reaching above root in the case of filters, e.g., $.^[?(@.appName === "app1")]). (That currently also gets a bad error, this._trace(...).filter is not a function.)
While trying out different filters, I noticed the following:
JSONPath({ path: '$.[?(@property === "appName" && @ === "app1")]^', json: { "version": 1, "appName": "app1" }, wrap: false });
The json passes filter and gets returned
{"version":1,"appName":"app1"}
JSONPath({ path: '$.[?(@.appName === "app1")]^', json: { "version": 1, "appName": "app1" }, wrap: false });
This returns
undefined
Is this behaviour expected? If yes, can we add a couple of more examples to documentation?
The text was updated successfully, but these errors were encountered: