Skip to content

Commit 8e9132f

Browse files
committed
doc: Update docs/json.md
1 parent aadda3d commit 8e9132f

File tree

2 files changed

+131
-3
lines changed

2 files changed

+131
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,16 @@ Quick Reference
531531
- [Quick Reference for VSCode](https://marketplace.visualstudio.com/items?itemName=jackiotyu.quick-reference)[jackiotyu](https://github.com/jackiotyu/vscode-quick-reference) 提供
532532

533533
<!--rehype:ignore:start-->
534+
## 开发
535+
536+
```sh
537+
# 克隆仓库
538+
$ git clone https://github.com/jaywcjlove/reference.git
539+
$ npm install # 安装依赖
540+
$ npm start # 启动监听,实时生成 HTML
541+
$ open dist/index.html # 在浏览器打开生成 HTML
542+
```
543+
534544
## License
535545

536546
MIT © [Kenny Wong](https://github.com/jaywcjlove)

docs/json.md

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ JSON 备忘清单
2727
"salary": 70000,
2828
"married": true,
2929
"children": [
30-
{"name": "Tom", "age": 9, "gender":"M"},
31-
{"name": "Ava", "age": 7, "gender":"F"}
30+
{"name": "Tom", "age": 9},
31+
{"name": "Ava", "age": 7}
3232
]
3333
}
3434
```
@@ -66,7 +66,7 @@ JSON 备忘清单
6666
{
6767
"url": "https://jaywcjlove.github.io",
6868
"msg" : "Hi,\n\"Quick Reference\"",
69-
"intro": "Share quick reference and cheat sheet for developers."
69+
"intro": "为开发人员分享快速参考和备忘单"
7070
}
7171
```
7272

@@ -198,6 +198,124 @@ Have to be delimited by double quotes
198198
}
199199
```
200200

201+
JSON 5
202+
----
203+
204+
### Objects
205+
206+
对象键可以是 ECMAScript 5.1 [IdentifierName](https://www.ecma-international.org/ecma-262/5.1/#sec-7.6)
207+
208+
```json
209+
{
210+
width: 1920,
211+
height: 1080,
212+
}
213+
```
214+
215+
数组可以有一个尾随逗号
216+
217+
```json
218+
[
219+
1,
220+
true,
221+
'three',
222+
]
223+
```
224+
225+
### 允许单行和多行注释
226+
227+
```js
228+
{
229+
// 一行注释
230+
"name": "Kenny"
231+
}
232+
```
233+
234+
多行注释
235+
236+
```js
237+
{
238+
/* 这是一个
239+
多行注释 */
240+
"name": "Kenny"
241+
}
242+
```
243+
244+
### 允许附加空白字符
245+
246+
代码点 | 描述
247+
:-- | ---
248+
`U+0009` | 水平制表符
249+
`U+000A` | 换行符
250+
`U+000B` | 垂直制表符
251+
`U+000C` | 换页符
252+
`U+000D` | 回车符
253+
`U+0020` | 空格
254+
`U+00A0` | 不间断空格
255+
`U+2028` | 行分隔符
256+
`U+2029` | 段落分隔符
257+
`U+FEFF` | 字节顺序标记
258+
Unicode Zs 类别 | 空格分隔符 Unicode 类别中的任何其他字符
259+
<!--rehype:className=left-align-->
260+
261+
### 数字
262+
263+
数字可能有前导或尾随小数点
264+
265+
```json
266+
{
267+
integer: 123,
268+
withFractionPart: 123.456,
269+
onlyFractionPart: .456,
270+
withExponent: 123e-456,
271+
}
272+
```
273+
274+
数字可以是十六进制
275+
276+
```json
277+
{
278+
positiveHex: 0xdecaf,
279+
negativeHex: -0xC0FFEE,
280+
}
281+
```
282+
283+
数字可以是正无穷大、负无穷大和 NaN。
284+
285+
```json
286+
{
287+
positiveInfinity: Infinity,
288+
negativeInfinity: -Infinity,
289+
notANumber: NaN,
290+
}
291+
```
292+
293+
数字可以以明确的加号开头
294+
295+
### 字符串
296+
<!--rehype:wrap-class=col-span-2-->
297+
298+
```js
299+
'Lorem ipsum dolor sit amet, \
300+
consectetur adipiscing elit.'
301+
```
302+
303+
以下是代表相同的意思
304+
305+
```js
306+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
307+
```
308+
309+
```json
310+
'\A\C\/\D\C'
311+
```
312+
313+
以下是代表相同的意思
314+
315+
```json
316+
'AC/DC'
317+
```
318+
201319
在 JavaScript 中访问 JSON
202320
----
203321

0 commit comments

Comments
 (0)