Filter expression with equals on array of numbers
Setup
Selector: $[?(@==42)]
[
0,
42,
-1,
41,
43,
42.0001,
41.9999,
null,
100
]
Results
Consensus
[
42
]
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@==42)]': Invalid array index definition “?(@==42)]”
Clojure (json-path)
¹
[
null
]
Elixir (ExJsonPath)
Not supported
syntax error before: '=='
Elixir (jaxon)
[]
Erlang (ejsonpath)
[]
[]
Java (com.github.jsurfer)
Not supported
line 1:5 no viable alternative at input '@=='
org.antlr.v4.runtime.misc.ParseCancellationException
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
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:6 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:6 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}")
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Rust (jsonpath)
[]
Rust (jsonpath_lib)
[]
dotNET (Manatee.Json)
Not supported
Sequence contains no elements
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(@==42)]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Errors
JavaScript (jsonpath-plus)
Invalid or unexpected token
PHP (Goessner)
²
ArgumentCountError
PHP (softcreatr-jsonpath)
Error: 'Malformed filter query'
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.