Filter expression on object
Setup
Selector: $[?(@.key)]
{"key": 42, "another": {"key": 1}}
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.key)]': Invalid array index definition “?(@.key)]”
Clojure (json-path)
¹
[
{
"key": 1
}
]
Cpp (jsoncons)
[
{
"key": 1
}
]
Dart (json_path)
[
{
"key": 1
}
]
Elixir (ExJsonPath)
Not supported
syntax error before: ')'
Elixir (jaxon)
[]
Elixir (warpath)
¹
[
{
"another": {
"key": 1
},
"key": 42
}
]
Erlang (ejsonpath)
[
{
"key": 1
}
]
[
{
"key": 1
}
]
[
{
"key": 1
}
]
[]
Not supported
[
{
"key": 1
}
]
[
{
"another": {
"key": 1
},
"key": 42
}
]
Haskell (jsonpath)
[
{
"key": 1
}
]
JavaScript (Goessner)
²
[
42,
{
"key": 1
}
]
JavaScript (brunerd)
[
42,
{
"key": 1
}
]
JavaScript (jsonpath)
[
{
"key": 1
}
]
JavaScript (jsonpath-plus)
[
{
"key": 1
}
]
Java (com.github.jsurfer)
[
{
"key": 1
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"another": {
"key": 1
},
"key": 42
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"another": {
"key": 1
},
"key": 42
}
]
PHP (galbar-jsonpath)
²
[
{
"key": 1
}
]
PHP (remorhaz-jsonpath)
[
{
"another": {
"key": 1
},
"key": 42
}
]
PHP (softcreatr-jsonpath)
[
{
"key": 1
}
]
Python (jsonpath)
²
[
{
"key": 1
}
]
Python (jsonpath-ng)
Not supported
JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')
Python (jsonpath-rw)
Not supported
JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')
Python (jsonpath2)
[
{
"another": {
"key": 1
},
"key": 42
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
{
"another": {
"key": 1
},
"key": 42
}
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
[
{
"another": {
"key": 1
},
"key": 42
}
]
Rust (jsonpath_plus)
[]
Scala (jsonpath)
[
{
"another": {
"key": 1
},
"key": 42
}
]
Swift (Sextant)
[
{
"another": {
"key": 1
},
"key": 42
}
]
dotNET (Json.NET)
[]
dotNET (JsonCons.JsonPath)
[
{
"key": 1
}
]
dotNET (JsonPath.Net)
[
{
"key": 1
}
]
dotNET (JsonPathLib)
[
{
"key": 1
}
]
dotNET (Manatee.Json)
[
{
"key": 1
}
]
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(@.key)]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Proposal (A)
[
{
"key": 1
}
]
Errors
key error: not found in object
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
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.