Only a $-rooted JSONPath query unwraps a list to its first match
The rule
- An extractor MUST reduce an array result to its first match where its engine is jsonpath, the path is
$-rooted, and extract-all is off. - It MUST NOT reduce an array result otherwise.
- A property-path engine MUST deliver an array result whole, even for a
$-prefixed path. - A jsonpath engine that falls back to property-path resolution MUST NOT unwrap.
- The extractor's reported JSONPath flag MUST report the
$prefix alone. - It MUST NOT depend on the engine in force.
What it means
Whether an array result gets reduced to its first match turns on which engine
ran, not on what the path string looks like. A $-rooted path evaluated by
the property-path engine is still read as a property path — the leading $
is not enough on its own to trigger the reduction. The flag that reports
whether the path looked like a JSONPath query is independent of this: it
answers the prefix question alone, so it can read true for a path the
property-path engine went on to deliver whole, unreduced.
Example
The evaluator returns the same two-element array either way; only the engine
differs, against the same $-rooted path.
["first", "second"]"first"Both report the path as a JSONPath query (is_jsonpath true); only the
second reduces it, and only the second counts two matches.
Why
Recorded under OPEN-25.