JSON5 格式标准 Data Exchange Format 官方文档 中英双语

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,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wtsolutions

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值