Is null valid JSON (4 bytes, nothing else)

前端 未结 2 960
别那么骄傲
别那么骄傲 2020-12-03 06:30

Hot debate today:

Is the text stream null valid JSON?

According to http://www.ietf.org/rfc/rfc4627.txt?number=4627:

...

相关标签:
2条回答
  • 2020-12-03 07:09

    [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 [].

    0 讨论(0)
  • 2020-12-03 07:09

    RFC 7159 drops 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.

    0 讨论(0)
提交回复
热议问题