Filter expression with in current object
Setup
Selector: $[?(2 in @.d)]
[{"d": [1, 2, 3]}, {"d": [2]}, {"d": [1]}, {"d": [3, 4]}, {"d": [4, 2]}]
Results
Consensus
Not supported
Other responses
Bash (JSONPath.sh)
[]
Clojure (json-path)
¹
[]
Elixir (jaxon)
[]
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
[]
JavaScript (Goessner)
²
[
{
"d": [
1,
2,
3
]
}
]
JavaScript (brunerd)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
JavaScript (jsonpath)
[]
JavaScript (jsonpath-plus)
[
{
"d": [
1,
2,
3
]
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
Objective-C (SMJJSONPath)
¹
³
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
PHP (galbar-jsonpath)
²
Not found
jsonpath returned false, this might indicate an error
Python (jsonpath)
²
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
Ruby (jsonpath)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
Swift (Sextant)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
dotNET (JsonPathLib)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
Errors
not enough arguments
wrong request: wrong request: ?(2 in @.d)
PHP (Goessner)
²
ArgumentCountError
PHP (softcreatr-jsonpath)
Error: 'Malformed filter query'
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(2 in @.d)]
panic occurred
Footnotes
- ¹ This implementation returns a single value where only one match is possible (instead of an array of a single value).
- ² This implementation returns a specific not found value if no match exists.
- ³ This implementation returns a specific not found value if a query that would regularly return a single match results in no match.