Array slice with negative step and start greater than end
Setup
Selector: $[0:3:-2]
["first", "second", "third", "forth", "fifth"]
Results
Consensus
[]
Not found consensus
This consensus applies for implementations which return a specific not found value if no match exists.
NOT_FOUND
Other responses
Bash (JSONPath.sh)
[
"first",
"second",
"third"
]
Clojure (json-path)
¹
"first"
Erlang (ejsonpath)
Not supported
syntax error before: '-'
[
"third",
"first"
]
Java (com.github.jsurfer)
Not supported
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.jayway.jsonpath)
¹
³
[
"first",
"second",
"third"
]
Kotlin (com.nfeld.jsonpathkt)
¹
[
"first",
"second",
"third"
]
Objective-C (SMJJSONPath)
¹
³
[
"first",
"second",
"third"
]
Perl (JSON-Path)
[
"third",
"second",
"first"
]
Python (jsonpath-ng)
Not supported
JsonPathParserError('Parse error at 1:5 near token : (:)')
Python (jsonpath-rw)
Not supported
Exception('Parse error at 1:5 near token : (:)')
Raku (JSON-Path)
Not supported
JSON path parse error at position 1
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
Not supported
path error:
$[0:3:-2]
^^^^^^
Rust (jsonpath_plus)
[
"third",
"first"
]
Swift (Sextant)
[
"first",
"second",
"third"
]
Errors
C (json-glib)
timeout: sending signal TERM to command ‘build/main’
Elixir (ExJsonPath)
FunctionClauseError
only support one range(from, to): [0 3 -2]
PHP (Goessner)
²
timeout: sending signal TERM to command ‘implementations/PHP_Goessner/run.sh’
PHP (softcreatr-jsonpath)
timeout: sending signal TERM to command ‘php’
Ruby (jsonpath)
step can't be negative
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.