Hacker News new | past | comments | ask | show | jobs | submit login

Isn't null an object?



The RFC says all JSON text must be an array or object, null is a value. JSON text is made up of JSON values.

per the RFC,

"JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and arrays)."

"An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array."


Hrmm. Later on it is explained:

2.1. Values

   A JSON value MUST be an object, array, number, or string, or one of
   the following three literal names:

      false null true


... so what you're receiving is technically a valid JSON value according to the RFC, no?

(I am so sorry for being this pedantic - but that RFC is marked 'informational', it's not actually a standard so much as a suggestion, and even worse, RFC 7159 obsoletes it and is an IETF standards track document - check out http://tools.ietf.org/html/rfc7159. The ambiguity is definitely removed in the updated version.)


If I'm reading it correctly: "null" would be a valid value, but a key/name would still need to be specified. So a blank document with the word "null" on it is invalid because the value of null has no key... but again, I may be reading it wrong.


{"key": null}

vs

null

I'm pretty sure they're both valid.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: