Standard JSON5 标准 JSON5
1.0.0 / March 2018 1.0.0 / 三月 2018
The JSON5 Data Interchange FormatThe JSON5 数据交换格式
Abstract 摘要
The JSON5 Data Interchange Format is a proposed extension to JSON that aims to make it easier for humans to write and maintain by hand. It does this by adding some minimal syntax features directly from ECMAScript 5.1.JSON5 数据交换格式是一个提议的 JSON 扩展,旨在通过直接添加一些来自 ECMAScript 5.1 的最小语法特性,使人类更容易手动编写和维护。
1Introduction 1 介绍
The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.JSON5 数据交换格式(JSON5)是 JSON 的超集,旨在通过扩展其语法以包括一些来自 ECMAScript 5.1 的生产来缓解 JSON 的一些限制。
Similar to JSON, JSON5 can represent four primitive types (strings, numbers, Booleans, and null) and two structured types (objects and arrays).与 JSON 类似,JSON5 可以表示四种原始类型(字符串、数字、布尔值和 null)以及两种结构化类型(对象和数组)。
A string is a sequence of zero or more Unicode characters. Note that this citation references the latest version of Unicode rather than a specific release. It is not expected that future changes in the Unicode specification will impact the syntax of JSON5.字符串是由零个或多个 Unicode 字符组成的序列。请注意,此引用引用的是 Unicode 的最新版本,而不是特定版本。预计 Unicode 规范的未来变化不会影响 JSON5 的语法。
An object is an unordered collection of zero or more name/value pairs, where a name is a string or identifier and a value is a string, number, Boolean, null, object, or array.对象是一个无序集合,包含零个或多个键值对,其中键是一个字符串或标识符,值是字符串、数字、布尔值、null、对象或数组。
An array is an ordered sequence of zero or more values.数组是一个有序的值序列。
1.1Summary of Features 1.1 功能概述
The following ECMAScript 5.1 features, which are not supported in JSON, have been extended to JSON5.以下 ECMAScript 5.1 特性,这些特性在 JSON 中不受支持,已经被扩展到 JSON5 中。
Objects 对象
- Object keys may be an ECMAScript 5.1 IdentifierName.对象的键可以是 ECMAScript 5.1 的标识符名称。
- Objects may have a single trailing comma.对象可以有单个尾随逗号。
Arrays 数组
- Arrays may have a single trailing comma.数组可以有单个尾随逗号。
Strings 字符串
- Strings may be single quoted.字符串可以使用单引号。
- Strings may span multiple lines by escaping new line characters.字符串可以通过转义换行符跨越多行。
- Strings may include character escapes.字符串可以包含字符转义。
Numbers 数字
- Numbers may be hexadecimal.数字可以是十六进制。
- Numbers may have a leading or trailing decimal point.数字可以有一个前导或尾随的小数点。
- Numbers may be IEEE 754 positive infinity, negative infinity, and NaN.数字可以是 IEEE 754 的正无穷、负无穷和 NaN。
- Numbers may begin with an explicit plus sign.数字可以以显式的加号开头。
Comments 评论
- Single and multi-line comments are allowed.允许单行和多行注释。
White Space 空白字符
- Additional white space characters are allowed.允许额外的空白字符。
1.2Short Example 1.2 简例
Example (Informative) 示例(信息性)
{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',],
"backwardsCompatible": "with JSON",
}
2Values 2 值
A JSON5 value must be an object, array, string, or number, or one of the three literal names true
, false
, or null
.JSON5 值必须是一个对象、数组、字符串、数字,或者是三个字面量名称之一: true 、 false 或 null 。
JSON5Value: JSON5 值:JSON5Null JSON5 空值JSON5Boolean JSON5 布尔值JSON5String JSON5 字符串JSON5Number JSON5 数字JSON5Object JSON5 对象JSON5Array JSON5 数组# 3Objects 3 个对象
An object structure is represented as a pair of curly brackets surrounding zero or more name/value pairs (or members). A name is a string or identifier. A single colon comes after each name, separating the name from the value. A single comma separates a value from a following name. A single comma may follow the name/value pair. The names within an object should be unique.对象结构用一对花括号表示,其中包含零个或多个名称/值对(或成员)。名称是一个字符串或标识符。每个名称之后跟一个单冒号,将名称与值分开。一个值之后跟一个单逗号,与后面的名称分开。名称/值对之后可以跟一个单逗号。对象内的名称应该是唯一的。
JSON5Object: JSON5 对象:{}{JSON5MemberList,opt} { JSON5 成员列表, 选择}JSON5MemberList: JSON5 成员列表:JSON5Member JSON5 成员JSON5MemberList,JSON5MemberJSON5 成员列表, JSON5 成员JSON5Member: JSON5 成员:JSON5MemberName:JSON5ValueJSON5 成员名称: JSON5 值JSON5MemberName: JSON5 成员名称:JSON5Identifier JSON5 标识符JSON5String JSON5 字符串An object whose names are all unique is interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Implementations may report the last name/value pair only, report an error or fail to parse the object, or report all of the name/value pairs, including duplicates.一个名称全部唯一的对象在互操作性方面是可行的,即所有接收该对象的软件实现都将同意名称-值映射。当对象内的名称不唯一时,接收此类对象的软件的行为是不可预测的。实现可能只报告最后一个名称/值对,报告错误或无法解析对象,或者报告所有名称/值对,包括重复项。
Implementations may make the ordering of object members visible to calling software. Implementations whose behavior does not depend on member ordering will be interoperable in the sense that they will not be affected by this.实现可能将对象成员的顺序对调用软件可见。那些行为不依赖于成员顺序的实现将在互操作性方面是可行的,即它们将不会受到影响。
Example (Informative) 示例(信息性)
// An empty object
{}
// An object with two properties
// and a trailing comma
{
width: 1920,
height: 1080,
}
// Objects can be nested
{
image: {
width: 1920,
height: 1080,
'aspect-ratio': '16:9',
}
}
// An array of objects
[
{ name: 'Joe', age: 27 },
{ name: 'Jane', age: 32 },
]
4Arrays 4 数组
An array structure is represented as square brackets surrounding zero or more values (or elements). Elements are separated by commas. A single comma may follow the final element.数组结构用方括号表示,括号内包含零个或多个值(或元素)。元素之间用逗号分隔。最后一个元素后面可以跟一个逗号。
JSON5Array: JSON5 数组:[][JSON5ElementList,opt] [ JSON5 元素列表, 可选 ]JSON5ElementList: JSON5 元素列表:JSON5Value JSON5 值JSON5ElementList,JSON5ValueJSON5 元素列表,JSON5 值There is no requirement that the values in an array be of the same type.数组中的值没有要求必须是同一类型。
Example (Informative) 示例(信息性)
// An empty array
[]
// An array with three elements
// and a trailing comma
[
1,
true,
'three',
]
// Arrays can be nested
[
[1, true, 'three'],
[4, "five", 0x6],
]
5Strings 5 字符串
A string begins and ends with single or double quotation marks. The same quotation mark that begins a string must also end the string. All Unicode characters may be placed within the quotation marks, except for the characters that must be escaped: the quotation mark used to begin and end the string, reverse solidus, and line terminators.字符串以单引号或双引号开始和结束。开始字符串的相同引号也必须结束字符串。所有 Unicode 字符都可以放在引号内,除了必须转义的字符:用于开始和结束字符串的引号、反斜杠和换行符。
JSON5String:: JSON5 字符串::“JSON5DoubleStringCharactersopt”" JSON5 双引号字符串字符可选"‘JSON5SingleStringCharactersopt’'JSON5 单引号字符串字符 opt’JSON5DoubleStringCharacters::'JSON5 双引号字符串字符::'JSON5DoubleStringCharacterJSON5DoubleStringCharactersopt’JSON5 双引号字符串字符 JSON5 双引号字符串字符 opt’JSON5SingleStringCharacters::'JSON5 单引号字符串字符::'JSON5SingleStringCharacterJSON5SingleStringCharactersoptJSON5 单个字符串字符 JSON5 单个字符串字符可选JSON5DoubleStringCharacter::JSON5 双引号字符串字符::SourceCharacterbut not one of " or \ or LineTerminator源字符但不是 " 或 \ 或 行终止符\EscapeSequence 转义序列LineContinuation 行续行符U+2028U+2029JSON5SingleStringCharacter::JSON5 单字符串字符::SourceCharacterbut not one of ’ or \ or LineTerminator源字符,但不是 ’ 或 \ 或 行终止符之一\EscapeSequence 转义序列LineContinuation 行续行符U+2028U+2029# 5.1Escapes 5.1 转义
Any character may be escaped. If the character is in the Basic Latin or Latin-1 Supplement Unicode character ranges (U+0000 through U+00FF), then it may be represented as a four-character sequence: a reverse solidus, followed by the lower case letter x
, followed by two hexadecimal digits that encode the character’s code point. A reverse solidus followed by the lower case letter x
must be followed by two hexadecimal digits.任何字符都可以进行转义。如果字符在基本拉丁或拉丁-1 补充 Unicode 字符范围内(U+0000 至 U+00FF),则可以表示为四个字符的序列:一个反斜杠,后跟小写字母 x ,然后是两个表示字符代码点的十六进制数字。一个反斜杠后跟小写字母 x 必须后跟两个十六进制数字。
If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF), then it may be represented as a six-character sequence: a reverse solidus, followed by the lower case letter u
, followed by four hexadecimal digits that encode the character’s code point. A reverse solidus followed by the lower case letter u
must be followed by four hexadecimal digits. The hexadecimal letters A though F can be upper or lower case.如果字符位于基本多语言平面(U+0000 至 U+FFFF),则它可以表示为一个六字符序列:一个反斜杠,后跟小写字母 u ,然后是四个十六进制数字,这些数字编码了字符的代码点。一个反斜杠后跟小写字母 u 必须后跟四个十六进制数字。十六进制字母 A 到 F 可以是大写或小写。
Example 1 (Informative) 示例 1(信息性)
A string containing only a single reverse solidus character may be represented as '\x5C'
or '\u005C'
.仅包含单个反斜杠字符的字符串可以表示为 ‘\x5C’ 或 ‘\u005C’ 。
To escape an extended character that is not in the Basic Multilingual Plane, the character is represented as a 12-character sequence, encoding the UTF-16 surrogate pair.要转义不在基本多语言平面的扩展字符,该字符表示为一个 12 字符序列,编码 UTF-16 代理对。
Example 2 (Informative) 示例 2(信息性)
A string containing only the musical score character 🎼 (U+1F3BC) may be represented as '\uD83C\uDFBC'
.仅包含音乐符号字符🎼(U+1F3BC)的字符串可以表示为 ‘\uD83C\uDFBC’ 。
Alternatively, there are two-character sequence escape representations of some popular characters. A decimal digit must not follow a reverse solidus followed by a zero.或者,还有一些流行字符的两种字符序列转义表示。一个十进制数字不能跟在反斜杠后跟零之后。
Table 1: Escape sequences
表 1:转义序列
Escape Sequence 转义序列 | Description 描述 | Code Point 代码点 |
---|---|---|
\' | Apostrophe 引号 | U+0027 '字符 |
\" | Quotation mark 引号 | U+0022 "字符 |
\\ | Reverse solidus 反斜杠 | U+005C |
\b | Backspace 退格键 | U+0008 |
\f | Form feed 换页符 | U+000C |
\n | Line feed 换行符 | U+000A |
\r | Carriage return 回车 | U+000D |
\t | Horizontal tab 水平制表符 | U+0009 |
\v | Vertical tab 垂直制表符 | U+000B |
\0 | Null 空值 | U+0000 |
Example 3 (Informative) 示例 3(信息性)
A string containing only a single reverse solidus character may be represented more compactly as '\\'
.一个仅包含单个反斜杠字符的字符串可以更紧凑地表示为 ‘\’ 。
A string may be continued on a new line by following a reverse solidus with one of the following line terminator sequences. The reverse solidus and line terminator sequence are not included in the string.字符串可以通过在反斜杠后跟以下之一的新行终止序列来继续在新行上。反斜杠和新行终止序列不包括在字符串中。
Table 2: Line terminator sequences
表 2:行终止序列
Code Points 代码点 | Description 描述 |
---|---|
U+000A | Line feed 换行符 |
U+000D | Carriage return 回车 |
U+000D U+000A 空白符 U+000D U+000A | Carriage return and line feed换行符和回车符 |
U+2028 | Line separator 行分隔符 |
U+2029 | Paragraph separator 段落分隔符 |
Example 4 (Informative) 示例 4(信息性)
The following strings represent the same information.以下字符串表示相同的信息。
'Lorem ipsum dolor sit amet, \
consectetur adipiscing elit.'
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
If any other character follows a reverse solidus, except for the decimal digits 1 through 9, that character will be included in the string, but the reverse solidus will not.如果反斜杠后面跟的是数字 1 到 9 之外的任何字符,则该字符将被包含在字符串中,但反斜杠本身不会。
Example 5 (Informative) 示例 5(信息性)
The following strings represent the same information.以下字符串表示相同的信息。
'\A\C\/\D\C'
'AC/DC'
5.2Paragraph and Line Separators5.2 段落和换行分隔符
Like JSON, JSON5 allows the Unicode code points U+2028 and U+2029 to appear unescaped in strings. Since ECMAScript 5.1 does not allow these code points in strings, authors should avoid including them in JSON5 documents. JSON5 parsers should produce a warning when they are found unescaped in strings. JSON5 generators should escape these code points in strings.与 JSON 一样,JSON5 允许 Unicode 码点 U+2028 和 U+2029 在字符串中未转义出现。由于 ECMAScript 5.1 不允许这些码点出现在字符串中,作者应避免在 JSON5 文档中包含它们。当 JSON5 解析器在字符串中找到未转义的这些码点时,应产生警告。JSON5 生成器应在字符串中转义这些码点。
6Numbers 6 个数字
The representation of numbers is similar to that used in most programming languages. A number may be represented in in base 10 using decimal digits, base 16 using hexadecimal digits, or the IEEE 754 values positive infinity, negative infinity, or NaN.数字表示与大多数编程语言中使用的表示类似。一个数字可以用十进制数字表示为十进制,用十六进制数字表示为十六进制,或者用 IEEE 754 值表示为正无穷、负无穷或 NaN。
JSON5Number:: JSON5 数字::JSON5NumericLiteral+JSON5NumericLiteral-JSON5NumericLiteral JSON5 数值字面量JSON5NumericLiteral:: JSON5 数值字面量::NumericLiteral 数值字面量Infinity 无穷大NaN 非数字Decimal numbers contain an integer component that may be prefixed with an optional plus or minus sign, which may be followed by a fraction part and/or an exponent part.十进制数包含一个整数部分,该部分可能以可选的正号或负号开头,可能后跟分数部分和/或指数部分。
A fraction part is a decimal point followed by one or more digits.分数部分是一个小数点后跟一个或多个数字。
An exponent part begins with the letter E in upper or lower case, which may be followed by a plus or minus sign. The E and optional sign are followed by one or more digits.指数部分以大写或小写的字母 E 开头,后面可能跟有一个加号或减号。E 和可选的符号后面跟着一个或多个数字。
Example 1 (Informative) 示例 1(信息性)
{
integer: 123,
withFractionPart: 123.456,
onlyFractionPart: .456,
withExponent: 123e-456,
}
Hexadecimal numbers contain the literal characters 0x
or 0X
that may be prefixed with an optional plus or minus sign, which must be followed by one or more hexadecimal digits. The hexadecimal letters A through F can be upper or lower case.十六进制数包含字面字符 0x 或 0X ,可能前面有一个可选的加号或减号,后面必须跟着一个或多个十六进制数字。十六进制字母 A 到 F 可以是大写或小写。
Example 2 (Informative) 示例 2(信息性)
{
positiveHex: 0xdecaf,
negativeHex: -0xC0FFEE,
}
The IEEE 754 value positive infinity must be the literal characters Infinity
and may be prefixed with an optional plus sign.IEEE 754 值正无穷必须表示为字符 Infinity ,并且可以有一个可选的正号前缀。
The IEEE 754 value negative infinity must be the literal characters -Infinity
.IEEE 754 值负无穷必须表示为字符 -Infinity 。
The IEEE 754 value NaN must be the literal characters NaN
and may be prefixed with an optional plus or minus sign.IEEE 754 值 NaN 必须表示为字符 NaN ,并且可以有一个可选的正号或负号前缀。
Example 3 (Informative) 示例 3(信息性)
{
positiveInfinity: Infinity,
negativeInfinity: -Infinity,
notANumber: NaN,
}
7Comments 7 注释
Comments can be either single or multi-line. Multi-line comments cannot nest. Comments may appear before and after any JSON5Token.注释可以是单行或多行。多行注释不能嵌套。注释可以出现在任何 JSON5Token 之前和之后。
A single line comment begins with two soliduses and ends with a LineTerminator or the end of the document. All Unicode characters may be placed within the start and end, except for a LineTerminator.单行注释以两个连续斜杠开始,以行终止符或文档结尾结束。可以在开始和结束之间放置所有 Unicode 字符,除了行终止符。
A multi-line comment begins with a solidus and an asterisk and ends with an asterisk and a solidus. All Unicode characters may be placed within the start and end, except for an asterisk followed by a solidus.多行注释以一个斜杠和一个星号开始,以一个星号和一个斜杠结束。所有 Unicode 字符都可以放在开始和结束之间,除了星号后面跟着一个斜杠。
Example (Informative) 示例(信息性)
// This is a single line comment.
/* This is a multi-
line comment. */
8White Space 8 空白字符
White space may appear before and after any JSON5Token.空白字符可以出现在任何 JSON5Token 之前和之后。
Table 3: White space
表 3:空白字符
Code Points 代码点 | Description 描述 |
---|---|
U+0009 | Horizontal tab 水平制表符 |
U+000A | Line feed 换行符 |
U+000B | Vertical tab 垂直制表符 |
U+000C | Form feed 换页符 |
U+000D | Carriage return 回车 |
U+0020 | Space 空间 |
U+00A0 | Non-breaking space 非换行空格 |
U+2028 | Line separator 行分隔符 |
U+2029 | Paragraph separator 段落分隔符 |
U+FEFF | Byte order mark 字节顺序标记 |
Unicode Zs category Unicode Zs 类别 | Any other character in the Space Separator Unicode category空白分隔符 Unicode 类别中的任何其他字符 |
9Grammar 9 语法
JSON5 is defined by a lexical grammar and a syntactic grammar. The lexical grammar defines productions that translate text into tokens, and the syntactic grammar defines productions that translate tokens into a JSON5 value.JSON5 由词法语法和句法语法定义。词法语法定义了将文本转换为标记的生产,句法语法定义了将标记转换为 JSON5 值的生成。
All productions that do not begin with the characters “JSON5” are defined by productions of the ECMAScript 5.1 Lexical Grammar.所有不以“JSON5”字符开头的生产由 ECMAScript 5.1 词法语法定义。
9.1Lexical Grammar 9.1 词汇语法
The lexical grammar for JSON5 has as its terminal symbols characters (Unicode code units) that conform to the rules for JSON5SourceCharacter. It defines a set of productions, starting from the goal symbol JSON5InputElement, that describe how sequences of such characters are translated into a sequence of input elements.JSON5 的词法语法以其终端符号为符合 JSON5SourceCharacter 规则的字符(Unicode 代码单元)。它定义了一组生产,从目标符号 JSON5InputElement 开始,描述了此类字符序列如何转换为输入元素序列。
Input elements other than white space and comments form the terminal symbols for the syntactic grammar for JSON5 and are called tokens. These tokens are the identifiers, literals, and punctuators of the JSON5 language. Simple white space and comments are discarded and do not appear in the stream of input elements for the syntactic grammar.输入元素(除了空白和注释)构成了 JSON5 语法中的终结符号,被称为标记。这些标记是 JSON5 语言的标识符、字面量和标点符号。简单的空白和注释将被丢弃,不会出现在输入元素的语法流中。
Productions of the lexical grammar are distinguished by having two colons “::” as separating punctuation.词法语法的产生式通过两个冒号“::”作为分隔标点来区分。
JSON5SourceCharacter::SourceCharacterJSON5InputElement:: JSON5 输入元素::WhiteSpace 空白字符LineTerminator 行终止符Comment 注释JSON5Token JSON5 令牌JSON5Token:: JSON5 令牌::JSON5Identifier JSON5 标识符JSON5Punctuator JSON5 标点符号JSON5String JSON5 字符串JSON5Number JSON5 数字JSON5Identifier:: JSON5 标识符::IdentifierName 标识符名称JSON5Punctuator::one of JSON5 分号符::之一{}[]:, 空集合符号JSON5Null:: JSON5 空值NullLiteral 空字面量JSON5Boolean:: JSON5 布尔值::BooleanLiteral 布尔字面量JSON5String:: JSON5 字符串::“JSON5DoubleStringCharactersopt”" JSON5 双引号字符串字符可选"‘JSON5SingleStringCharactersopt’'JSON5 单引号字符串字符 opt’JSON5DoubleStringCharacters::'JSON5 双引号字符串字符::'JSON5DoubleStringCharacterJSON5DoubleStringCharactersopt’JSON5 双引号字符串字符 JSON5 双引号字符串字符 opt’JSON5SingleStringCharacters::'JSON5 单引号字符串字符::'JSON5SingleStringCharacterJSON5SingleStringCharactersoptJSON5 单个字符串字符 JSON5 单个字符串字符可选JSON5DoubleStringCharacter::JSON5 双引号字符串字符::SourceCharacterbut not one of " or \ or LineTerminator源字符但不是 " 或 \ 或 行终止符之一\EscapeSequence 转义序列LineContinuation 行续行符U+2028U+2029JSON5SingleStringCharacter::JSON5 单字符串字符::SourceCharacterbut not one of ’ or \ or LineTerminator源字符,但不是 ’ 或 \ 或 行终止符之一\EscapeSequence 转义序列LineContinuation 行续行符U+2028U+2029JSON5Number:: JSON5 数字::JSON5NumericLiteral+JSON5NumericLiteral-JSON5NumericLiteral JSON5 数值字面量JSON5NumericLiteral:: JSON5 数值字面量::NumericLiteral 数字字面量Infinity 无穷大NaN 非数字# 9.2Syntactic Grammar 9.2 句法语法
The syntactic grammar for JSON5 has tokens defined by the lexical grammar as its terminal symbols. It defines a set of productions, starting from the goal symbol JSON5Text, that describe how sequences of tokens can form syntactically correct JSON5 values.JSON5 的语法语法由词法语法定义的词素作为其终端符号。它定义了一组从目标符号 JSON5Text 开始的产生式,描述了如何将词素的序列形成语法正确的 JSON5 值。
When a stream of characters is to be parsed as a JSON5 value, it is first converted to a stream of input elements by repeated application of the lexical grammar; this stream of input elements is then parsed by a single application of the syntactic grammar. The program is syntactically in error if the tokens in the stream of input elements cannot be parsed as a single instance of the goal nonterminal JSON5Text, with no tokens left over.当一个字符流被解析为 JSON5 值时,它首先通过重复应用词法语法被转换为输入元素流;然后通过单次应用语法语法来解析这个输入元素流。如果输入元素流中的词素不能被解析为目标非终结符 JSON5Text 的单个实例,且没有剩余的词素,则程序在语法上是错误的。
Productions of the syntactic grammar are distinguished by having just one colon “:” as punctuation.语法句子的生产以只有一个冒号“:”作为标点符号为特征。
JSON5Text: JSON5 文本:JSON5Value JSON5 值JSON5Value: JSON5 值:JSON5Null JSON5 空值JSON5Boolean JSON5 布尔值JSON5String JSON5 字符串JSON5Number JSON5 数字JSON5Object JSON5 对象JSON5Array JSON5 数组JSON5Object: JSON5 对象:{}{JSON5MemberList,opt} { JSON5 成员列表, 选择}JSON5MemberList: JSON5 成员列表:JSON5Member JSON5 成员JSON5MemberList,JSON5MemberJSON5 成员列表, JSON5 成员JSON5Member: JSON5 成员:JSON5MemberName:JSON5ValueJSON5 成员名称: JSON5 值JSON5MemberName: JSON5 成员名称:JSON5Identifier JSON5 标识符JSON5String JSON5 字符串JSON5Array: JSON5 数组:[][JSON5ElementList,opt] [ JSON5 元素列表, 可选 ]JSON5ElementList: JSON5 元素列表:JSON5Value JSON5 值JSON5ElementList,JSON5ValueJSON5 元素列表,JSON5 值# 10Parsers 10 个解析器
A JSON5 parser transforms a JSON5 text into another representation. A JSON5 parser must accept all texts that conform to the JSON5 grammar. A JSON5 parser may accept non-JSON5 forms or extensions.JSON5 解析器将 JSON5 文本转换为另一种表示形式。JSON5 解析器必须接受所有符合 JSON5 语法的文本。JSON5 解析器可以接受非 JSON5 形式或扩展。
An implementation may set limits on the size of texts that it accepts, the maximum depth of nesting, the range and precision of numbers, and the length and character contents of strings.实现可以对其接受的文本大小、最大嵌套深度、数字的范围和精度以及字符串的长度和字符内容设置限制。
11Generators 11 生成器
A JSON5 generator produces JSON5 text. The resulting text must strictly conform to the JSON5 grammar.JSON5 生成器生成 JSON5 文本。生成的文本必须严格符合 JSON5 语法。
AConformance A 一致性
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.本文档中的关键词“必须”、“禁止”、“必需”、“应当”、“不应该”、“推荐”、“允许”和“可选”应按照 RFC 2119 进行解释。然而,为了可读性,这些词在本规范中并不全部使用大写字母。
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes.本规范的所有文本都是规范性文本,除非明确标记为非规范性文本、示例和注释。
Examples in this specification are introduced with the words “for example” or are set apart from the normative text like this:本规范中的示例以“例如”等词语引入,或像这样与规范性文本区分开来:
Example (Informative) 示例(信息性)
This is an example of an informative example.这是一个信息性示例的例子。
Informative notes begin with the word “Note” and are set apart from the normative text like this:信息性注释以“注意”一词开头,并像这样与规范性文本区分开来:
Note 注意This is an informative note.这是一个信息性笔记。
BLicense B 许可证
The MIT License (MIT)
Copyright © 2017 Aseem Kishore, Jordan Tucker版权所有 © 2017 阿西姆·基肖尔,乔丹·塔克
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:以下条件为准,特此免费授予任何获得本软件及其相关文档副本(以下简称“软件”)的人士,在软件中不受限制地处理软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供者提供软件的人士进行此类操作:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.软件按“原样”提供,不提供任何形式的保证,无论是明示的、暗示的,还是关于适销性、特定用途适用性或非侵权的保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论这些责任是因合同、侵权或其他原因引起的,无论这些责任是否与软件或其使用或其他方式有关。