An extraction that matches nothing is a miss; a matched null is delivered
A path that matches nothing and a path that matches a null give different answers, and the extractor keeps them apart, as JSONPath does. Only a miss falls back to the default.
The rule
Normative: this is the rule
- An extraction that evaluates cleanly and matches nothing is a miss.
- On a miss, the configured default MUST be delivered, the extractor MUST report success as
false, and the node MUST succeed. - An extraction that matches a
nullMUST delivernulland report success astrue. - A matched
false,0,"",[]or{}MUST be delivered as found, and success reported astrue.
Why
References
Further reading
- RFC 9535JSONPath: Query Expressions for JSONTells a query that selects no node apart from one that selects a node whose value is null. This rule keeps the same distinction for every engine.
Fixtures
Test cases whose outcome this rule decides. A case compares absent, null and empty members exactly; the fixtures README defines each operation. Where a case and the rule disagree, the rule is right.
A matched false, 0 or empty string is delivered as found extract
{ "given": { "data": { "a": false }, "path": "$.a", "default": "fallback" }, "expect": { "value": false, "success": true } }A query that matches null delivers null and reports a match extract
{ "given": { "data": { "a": null }, "path": "$.a", "default": "fallback" }, "expect": { "value": null, "success": true } }A query that matches nothing delivers the default and reports a miss extract
{ "given": { "data": { "a": 1 }, "path": "$.b", "default": "fallback" }, "expect": { "value": "fallback", "success": false } }
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-24 · changed in spec 1.0