Array slice with step and leading zeros
Setup
Selector: $[010:024:010]
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
Results
Consensus
[
10,
20
]
Other responses
Bash (JSONPath.sh)
[
8,
16
]
Clojure (json-path)
¹
10
Cpp (jsoncons)
[
8,
16
]
Elixir (jaxon)
[]
JavaScript (jsonpath)
Not supported
Parse error on line 1:
$[010:024:010]
---^
Expecting ']', ',', got 'ARRAY_SLICE'
Java (com.github.jsurfer)
Not supported
line 1:2 no viable alternative at input '[010'
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.jayway.jsonpath)
¹
³
[
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
]
Kotlin (com.nfeld.jsonpathkt)
¹
[
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
]
Objective-C (SMJJSONPath)
¹
³
[
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
]
PHP (Goessner)
²
[
20
]
PHP (remorhaz-jsonpath)
Not supported
Error: 'Failed to build AST from JSONPath query: $[010:024:010]'
Python (jsonpath-ng)
Not supported
JsonPathParserError('Parse error at 1:9 near token : (:)')
Python (jsonpath-rw)
Not supported
Exception('Parse error at 1:9 near token : (:)')
Python (jsonpath2)
Not supported
line 1:3 mismatched input '10' expecting {']', ','}
ValueError("line 1:3 mismatched input '10' expecting {']', ','}")
Raku (JSON-Path)
Not supported
JSON path parse error at position 1
Ruby (jsonpath)
[
8,
16
]
Rust (jsonpath)
Not supported
parsing error
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[010:024:010]
| ^---
|
= expected unionChild or unionArraySlice
Proposal (A)
Not supported
x 1:2-1:2 RecursiveDescentChildren
| $[010:024:010]
| ^
| x 1:2-1:2 BracketChildren
| | $[010:024:010]
| | ^
| | x 1:2-1:2 DotChild
| | | $[010:024:010]
| | | ^
| | |
|/ /
| |
|/
x 1:2-1:2 Operator
| $[010:024:010]
| ^
o 1:1-1:2 Start
$[010:024:010]
^
Errors
only support one range(from, to): [010 024 010]
JavaScript (brunerd)
Octal indices are disallowed: 010
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.