Filter expression with equals on object
Setup
Selector: $[?(@.key==42)]
{
"a": {"key": 0},
"b": {"key": 42},
"c": {"key": -1},
"d": {"key": 41},
"e": {"key": 43},
"f": {"key": 42.0001},
"g": {"key": 41.9999},
"h": {"key": 100},
"i": {"some": "value"}
}
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.key==42)]': Invalid array index definition “?(@.key==42)]”
Clojure (json-path)
¹
[
{
"some": "value"
}
]
Cpp (jsoncons)
[
{
"key": 42
}
]
Dart (json_path)
[
{
"key": 42
}
]
Elixir (ExJsonPath)
[
{
"key": 42
}
]
Elixir (jaxon)
[]
Elixir (warpath)
¹
[]
Erlang (ejsonpath)
[
{
"key": 42
}
]
[
{
"key": 42
}
]
[]
[
{
"key": 42
}
]
[
{
"key": 42
}
]
[]
Haskell (jsonpath)
[
{
"key": 42
}
]
JavaScript (Goessner)
²
Not found
jsonpath returned false, this might indicate an error
JavaScript (brunerd)
[]
JavaScript (jsonpath)
[
{
"key": 42
}
]
JavaScript (jsonpath-plus)
[
{
"key": 42
}
]
JavaScript (jsonpathly)
[]
Java (com.github.jsurfer)
[
{
"key": 42
}
]
Java (com.jayway.jsonpath)
¹
³
[]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[]
PHP (galbar-jsonpath)
[
{
"key": 42
}
]
PHP (remorhaz-jsonpath)
[]
PHP (softcreatr-jsonpath)
[
{
"key": 42
}
]
Python (jsonpath)
²
[
{
"key": 42
}
]
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)
Not supported
line 1:10 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:10 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}")
Python (python-jsonpath)
[
{
"key": 42
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[]
Rust (jsonpath)
[]
Rust (jsonpath_lib)
[]
Rust (jsonpath_plus)
[
{
"key": 42
}
]
Rust (serde_json_path)
[
{
"key": 42
}
]
Scala (jsonpath)
[]
Swift (Sextant)
[]
dotNET (Json.NET)
[]
dotNET (JsonCons.JsonPath)
[
{
"key": 42
}
]
dotNET (JsonPath.Net)
[
{
"key": 42
}
]
dotNET (JsonPathLib)
[
{
"key": 42
}
]
dotNET (Manatee.Json)
[
{
"key": 42
}
]
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.