Bracket notation with negative number on short array

Setup

Selector: $[-2]

["one element"]

Results

Consensus

[]

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).

null

Not found consensus

This consensus applies for implementations which return a specific not found value if no match exists.

NOT_FOUND

Scalar not found consensus

This consensus applies for implementations which returns a specific not found value when a query that would regularly return a single match results in no match.

NOT_FOUND

Other responses

PHP (galbar-jsonpath) ²

[
  "one element"
]

PHP (remorhaz-jsonpath)

[
  "one element"
]

PHP (softcreatr-jsonpath)

[
  "one element"
]

Raku (JSON-Path)

Not supported

JSON path parse error at position 1

Ruby (jsonpath)

[
  "one element"
]

Rust (jsonpath)

Not supported

parsing error

Rust (jsonpath_lib)

[
  "one element"
]

Errors

Clojure (json-path) ¹

java.lang.IndexOutOfBoundsException nil

Golang (github.com-PaesslerAG-jsonpath) ¹

index -2 out of bounds

Golang (github.com-oliveagle-jsonpath) ¹

index out of range: len: 1, idx: -2

Python (jsonpath-ng)

IndexError('list index out of range')

Python (jsonpath-rw)

IndexError('list index out of range')

dotNET (Json.NET)

Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

Footnotes