--- id: LANG-15 family: GR-LANG level: extended profiles: [runtime] posture: normative-target added: "1.0" changed: "1.0" source: https://flowdrop.io/spec/rules/gr-lang/lang-15 specification: FlowDrop Workflow Specification 1.0 licence: CC BY 4.0 --- # LANG-15 — A single JSONPath match is unwrapped unless the path selects many *GR-LANG (Part I) · level: extended · profiles: runtime · added in 1.0* 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. > > 1. A JSONPath query that returns exactly one match MUST yield that match rather than a one-element array, unless the path is written to select many, containing a wildcard, a filter or a slice. > > 2. A path written to select many MUST yield an array, even when only one item matched. ## What it means Whether a result comes back as a bare value or as an array 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 array 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. ```json title="What the ordinary path returns" verdict="unwrapped" "Test Store" ``` ```json title="What the filter path returns" verdict="list" ["Book 3"] ``` ## Why Recorded under [OPEN-25](https://flowdrop.io/spec/rulings/open-25). ## Related rules - Referenced by: LANG-23 --- Rule identifiers are permanent and are never renumbered. This specification carries no implementation status: each implementation publishes its own standing against these rules. Licensed CC BY 4.0.