jsonlintdotcom icon indicating copy to clipboard operation
jsonlintdotcom copied to clipboard

Strings, numbers, null as top level objects should throw a warning, not an error

Open umbrae opened this issue 14 years ago • 3 comments

Essentially all JSON libraries respect these values as top level objects, even if the spec technically prohibits. We should follow suit.

umbrae avatar Jun 29 '11 20:06 umbrae

'1', '"a"', 'null', 'true' and 'false' are valid JSON, according to the spec (http://www.json.org/) .

But, http://jsonlint.com/ can't parse these.

Parse error on line 1:
1
^
Expecting '{', '['

"pure JavaScript version" is ok : http://zaach.github.com/jsonlint/

tonextone avatar Jun 16 '12 10:06 tonextone

From the spec at http://www.ietf.org/rfc/rfc4627.txt:

A JSON text is a serialized object or array. JSON-text = object / array

It should still show a warning though.

umbrae avatar Jun 16 '12 11:06 umbrae

Ah, I have been misunderstood.

http://jsonlint.com/ is right.

Thanks.

tonextone avatar Jun 18 '12 03:06 tonextone