2. JSON Grammar

A JSON text is a sequence of tokens. The set of tokens includes six
structural characters, strings, numbers, and three literal names.

A JSON text is a serialized object or array.

JSON-text = object / array

These are the six structural characters:

[...]

However, the RFC-4627 status declares that it "does not specify an Internet standard of any kind". Instead, the official standard for JSON is the recently-published ECMA-404. Unlike RFC-4627, ECMA-404's description of valid JSON text does not include any requirement that it be an object or an array. For example, the section most similar to the quote above is missing that requirement:

4 JSON Text

A JSON text is a sequence of tokens formed from Unicode code points that conforms to the JSON value
grammar. The set of tokens includes six structural tokens, strings, numbers, and three literal name tokens.

The six structural tokens:

[...]

Given this new specification, are encoded non-array non-object top-level values considered valid JSON texts?

1 Answer
1

Douglas Crockford posted a comment on this Google+ post which helped me start to clarify things:

JSON is just a grammar, and the grammar includes numbers and strings. Uses of JSON must necessarily be more restrictive. RFC-4627 is one possible use, and was never intended to be the standard for JSON itself.

We cannot say that non-array non-object JSON texts are generally invalid, just that it is not valid to use them with internet media type application/json, per RFC-4627.

Representations of non-object non-array values are valid JSON texts per ECMA-404, which is the only currently published standard that might be identified as "the JSON specification".

However, it turns out that the IETF is likely to soon publish a replacement to RFC-4627 which will also be a specification of JSON. Its latest draft still includes the restriction on JSON texts, but also mentions that JSON has be specified in several places and that these specifications vary slightly. The draft specifically mentions that the definition of JSON in ECMA-262 (the ECMAScript/JavaScript specification) does not share the top-level value restriction.

Therefore, the question of whether non-object non-arrays are valid JSON texts must be disambiguated:

Is "hello" a valid JSON text as specified in RFC-4627 and its successor?

See my answer to stackoverflow.com/questions/18419428/… which updates the definition found in RFC-7158 which does allow a string as the top-level JSON text. That answer also clarifies what RFC-7159 is.
– JohannMar 12 '14 at 18:58