frnhr frnhr - 4 months ago 27
JSON Question

Minimal JSON data structure containing a value

Looking at json spec, I'm not sure whether a

value
is permitted to stand alone, or is only permitted as part of
object
or
array
structure.

This is valid JSON:

[123]


But is this valid JSON:

123

Answer

Per ECMA-404, The JSON Data Interchange Standard (pdf), which is linked from the JSON.org page you linked:

A JSON text is a sequence of tokens formed from Unicode code points that conforms to the JSON value grammar.

And:

A JSON value can be an object, array, number, string, true, false, or null.

As such, the value 123 is valid JSON, representing an integer.