I’ve seen so many complicated questions in SO whether or not some complicated structure is considered to be valid JSON.
But what about something on the other end of the spectrum?
"12345"
Is the above valid JSON?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, in most contexts. It is valid JSON syntax representing a JSON value.
The confusion around this comes from Douglas Crockford’s RFC 4627, which originally defined the
application/jsoninternet media type in 2006. It said that:However, as Crockford explained in a post in 2013 (unfortunately deleted with rest of Google+, but archived here):
The example string is a valid JSON value, but it would have been incorrect to use it as the full "JSON text" body of an
application/jsonHTTP response. However, that’s no longer true: RFC-4627 was obsoleted in 2014 with the publication of RFC 7159, which lets you use any JSON value:A "standard for JSON itself" was also published in 2013, as ECMA-404, and JSON was also defined in edition 5.1 of the ECMAScript (JavaScript) specification ECMA-262. These specifications and most parsers allow any JSON value as a complete JSON text, even if it’s just a simple string.