summaryrefslogtreecommitdiffhomepage
path: root/zh-cn/json-cn.html.markdown
diff options
context:
space:
mode:
authorBoris Verkhovskiy <boris.verk@gmail.com>2024-04-03 04:31:13 -0700
committerGitHub <noreply@github.com>2024-04-03 04:31:13 -0700
commitfbf132752b743d0f43c3395da0699bee53da22df (patch)
tree56da43c86e1aebd24e3913b405e21d6f2812e9a3 /zh-cn/json-cn.html.markdown
parent247dc6e86c1421fa031e4b61c42c05ca6e09bfb0 (diff)
parentc166f2acb295627c5ae305a6dd517a27ca8fece6 (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'zh-cn/json-cn.html.markdown')
-rw-r--r--zh-cn/json-cn.html.markdown43
1 files changed, 33 insertions, 10 deletions
diff --git a/zh-cn/json-cn.html.markdown b/zh-cn/json-cn.html.markdown
index 73d3eb57..f5842c07 100644
--- a/zh-cn/json-cn.html.markdown
+++ b/zh-cn/json-cn.html.markdown
@@ -8,24 +8,30 @@ filename: learnjson-cn.json
lang: zh-cn
---
-因为JSON是一个极其简单的数据交换格式,本教程最有可能成为有史以来最简单的
-Learn X in Y Minutes。
+JSON是一个极其简单的数据交换格式。按[json.org](https://json.org)说的,它对人类易读易写,对机器易解析易生成。
-纯正的JSON实际上没有注释,但是大多数解析器都
-接受C-风格(//, /\* \*/)的注释。为了兼容性,最好不要在其中写这样形式的注释。
+一段JSON可以是下文列出的类型的任意值,但实际一般按以下两种方式之一呈现:
+
+* 一个键值对的集合(`{ }`)。按不同语言,这可能被理解为对象/记录/结构体/字典/哈希表/有键列表/关联数组
+* 一个有序的值列表(`[ ]`)。按不同语言,这可能被理解为数组/向量/列表/序列
+
+纯正的JSON实际上没有注释,但是大多数解析器都接受C-风格(//, /\* \*/)的注释。一些解析器还容许trailing comma,即最后一个数组元素或最后一个对象属性之后的逗号。不过为了兼容性最好避免。
因此,本教程的一切都会是100%有效的JSON。幸亏,它的表达能力很丰富。
支持的数据类型:
-- 字符串: "hello", "\"A quote.\"", "\u0abe", "Newline.\n"
-- 数字: 23, 0.11, 12e10, 3.141e-10, 1.23e+4
-- 对象: { "key": "value" }
-- 数组: ["Values"]
-- 其他: true, false, null
+* 字符串:`"hello"`、`"\"A quote.\""`、`"\u0abe"`、`"Newline.\n"`
+* 数字:`23`、`0.11`、`12e10`、`3.141e-10`、`1.23e+4`
+* 对象:`{ "key": "value" }`
+* 数组:`["Values"]`
+* 其它:`true`、`false`、`null`
```json
{
+ "key": "value",
+
+ "keys": "must always be enclosed in double quotes",
"numbers": 0,
"strings": "Hellø, wørld. All unicode is allowed, along with \"escaping\".",
"has bools?": true,
@@ -55,6 +61,23 @@ Learn X in Y Minutes。
]
],
- "that was short": "And, you're done. You now know everything JSON has to offer."
+ "alternative style": {
+ "comment": "check this out!"
+ , "comma position": "doesn't matter, if it's before the next key, it's valid"
+ , "another comment": "how nice"
+ },
+
+
+
+ "whitespace": "Does not matter.",
+
+
+
+ "that was short": "And done. You now know everything JSON has to offer."
}
```
+
+## 进一步阅读
+
+* [JSON.org](https://www.json.org/json-zh.html) 完美图解JSON的一切
+* [JSON Tutorial](https://www.youtube.com/watch?v=wI1CWzNtE-M) 简要介绍