2. JSON Grammar (JSON语法)
A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names.
JSON文本是一个token序列。token集合包括六个结构字符、字符串、数字和三个字面量名称。
A JSON text is a serialized value. Note that certain previous specifications of JSON constrained a JSON text to be an object or an array. Implementations that generate only objects or arrays where a JSON text is called for will be interoperable in the sense that all implementations will accept these as conforming JSON texts.
JSON文本是一个序列化的值。注意,JSON的某些早期规范将JSON文本限制为对象或数组。在需要JSON文本的地方只生成对象或数组的实现将是互操作的,因为所有实现都会接受这些作为符合规范的JSON文本。
JSON-text = ws value ws
These are the six structural characters:
以下是六个结构字符:
begin-array = ws %x5B ws ; [ left square bracket (左方括号)
begin-object = ws %x7B ws ; { left curly bracket (左花括号)
end-array = ws %x5D ws ; ] right square bracket (右方括号)
end-object = ws %x7D ws ; } right curly bracket (右花括号)
name-separator = ws %x3A ws ; : colon (冒号)
value-separator = ws %x2C ws ; , comma (逗号)
Insignificant whitespace is allowed before or after any of the six structural characters.
在六个结构字符中的任何一个之前或之后都允许无意义的空白字符。
ws = *(
%x20 / ; Space (空格)
%x09 / ; Horizontal tab (水平制表符)
%x0A / ; Line feed or New line (换行符)
%x0D ) ; Carriage return (回车符)