Skip to content

A string context is parsed as JSON where it parses

The rule

Normative: this is the rule
  1. Where the evaluation context is a string, it MUST be parsed as JSON.
  2. The path MUST query the parsed value.
  3. A string that is not valid JSON MUST be used as-is.
  4. The string null parses to null, like any other JSON document.

What it means

Whether a string context is parsed turns entirely on whether it parses, not on whether it looks like ordinary text or looks like data. The sharp edge is the four-character string "null": it reads like the kind of text a pass-through would leave alone, but it is itself a complete, valid JSON document, so it decodes to the JSON value null rather than surviving as the four-letter word. Nothing about the surrounding path decides this — the context alone does.

Example

The context is a string in both cases; only whether it parses as JSON decides what querying the root returns.

A context that is the word nullcontext
"null"
What querying the root of it returnsdecoded
null
A context that is a JSON object as textcontext
"{\"name\": \"Test\", \"value\": 123}"
What querying its name returnsdecoded
"Test"

Why

Recorded under OPEN-25.

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-16 · changed in spec 1.0