What is the minimum valid JSON?

后端 未结 8 1911
慢半拍i
慢半拍i 2020-11-22 16:01

I\'ve carefully read the JSON description http://json.org/ but I\'m not sure I know the answer to the simple question. What strings are the minimum possible valid JSON?

8条回答
  •  难免孤独
    2020-11-22 17:01

    Yes, yes, yes, yes, and yes. All of them are valid JSON value literals.

    However, the official RFC 4627 states:

    A JSON text is a serialized object or array.

    So a whole "file" should consist of an object or array as the outermost structure, which of course can be empty. Yet, many JSON parsers accept primitive values as well for input.

提交回复
热议问题