RFC 7159 and its successor RFC 8259 drop the limitation that a JSON text must be an object or an array. The grammar specifies:
JSON-text = ws value ws
where
value = false / null / true / object / array / number / string
Thus, "null" is now a valid JSON document.
Answer from niksnut on Stack OverflowRFC 7159 and its successor RFC 8259 drop the limitation that a JSON text must be an object or an array. The grammar specifies:
JSON-text = ws value ws
where
value = false / null / true / object / array / number / string
Thus, "null" is now a valid JSON document.
[Note! This answer is no longer correct, see answer by @niksnut.]
Yes, both statements must be true. The literal token null is a JSON value. A JSON text is a serialized object or array, which requires {} or [].
8G76: an empty file is not a valid JSON document
How do you validate if a string is a valid JSON string?
Best Practices to send for Empty Values of a JSON API?
Better ways to validate if non-nullable field was provided in JSON in API request
What do you choose? Getting lots of conflicting answers.
-
Null
-
Undefined (Omitted from JSON)
-
Empty of that type?
-
String = ""
-
Number = 0
-
Boolean = false
-
Array = []
-
Object = {}
-
CMS JSON API to be consumed by JS Framework Frontend