Bracket notation with number -1
Setup
Selector: $[-1]
["first", "second", "third"]
Results
Consensus
[
"third"
]
Scalar consensus
The scalar consensus applies for implementations which return a single value where only one match is possible (instead of an array of a single value).
"third"
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
[]
Elixir (jaxon)
[]
JavaScript (Goessner)
²
Not found
jsonpath returned false, this might indicate an error
JavaScript (jsonpath)
[]
JavaScript (jsonpath-plus)
[]
Java (com.github.jsurfer)
[]
PHP (Goessner)
²
Not found
jsonpath returned false, this might indicate an error
Python (jsonpath)
²
Not found
jsonpath returned false, this might indicate an error
Raku (JSON-Path)
Not supported
JSON path parse error at position 1
Rust (jsonpath)
Not supported
parsing error
dotNET (JsonPathLib)
[]
Errors
index -1 out of bounds
dotNET (Json.NET)
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
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.