'How to use JSONPath to return a full array filtered by its elements?
How to return a full array filtered by its elements using JSONPath?
It seems like when the current node @ is an array the filter is acting on the array elements and not on the array.
e.g.
I want to return the array that its first element is 1
{
"a": [1,2,3],
"b": [4,5,6]
}
Query:
$.*[?(@[0]==1)]
Returns:
[]
I would expect it to return
[[1,2,3]]
While the following query:
$.*[?(@==1)]
Returns:
[ 1 ]
I tried it with different JSONPath engines on https://jsonpath.herokuapp.com/ and didn't manage to get the expected result.
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Delta George |
