FlowDrop Workflow Specification 1.0-draft

A single JSONPath match is unwrapped unless the path selects many

Arity is read off the path, not off the result, so a query written to select many keeps a list shape even on the day it matches exactly one thing.

The rule

Normative: this is the rule

A JSONPath query that returns exactly one match yields that match rather than a one-element list, unless the path is written to select many, containing a wildcard, a filter or a slice, in which case the result stays a list even when only one item matched.

What it means

Whether a result comes back as a bare value or as a list is decided by reading the query's own syntax, not by counting how many things it happened to match today. A query with no wildcard, filter or slice in it is written to find one thing, so a single match is handed back directly. A query that carries one of those — even when, on a given record, it only ever matches one item — keeps its list shape regardless, because the query was written to select many and the day it matches one is not a promise it always will.

Example

Two queries against the same stored data: $.store.name, an ordinary path, and $.store.books[?(@.price < 9)].title, a filter written to select many — each matching exactly one item.

What the ordinary path returnsunwrapped
"Test Store"
What the filter path returnslist
["Book 3"]
Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0-draft · LANG-15 · changed in spec 1.0