Skip to content

Extracting all matches for a property path always yields a list

The rule

Normative: this is the rule
  1. Extracting all matches for a property path MUST yield an array.
  2. A single match MUST be wrapped in a one-element array.
  3. A path that reads a stored null matches it, and MUST yield a one-element array holding null.
  4. A path that matches nothing MUST yield the empty array.

What it means

Extracting all matches never hands back the bare value it found — even where the path can only ever match one thing, the result is still an array, so calling code does not need two shapes depending on what the path looked like. The sharper edge is the null case: a path that reads a stored null found something, so it comes back as a one-element array holding that null. Only a path that matched nothing at all gives the empty array.

Example

Extracting all matches for store.name, a path that can only ever match one value:

What extracting all matches returns for a single matchwrapped
["Test Store"]
A context whose path reads a stored nullmatched
{"key": null}
What extracting all matches returns for itwrapped
[null]

Why

Recorded under OPEN-25, OPEN-26.

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · LANG-19 · changed in spec 1.0