Sign in Join
Wiki copytemporary

JSON/zh CN

한국어 · English · Polski · Suomi · Русский · 中文(中国) · 日本語

概述

JSON (JavaScript Object Notation) 是种数据表现形式,它提供了简单的文本标准化数据交换格式。正如其名称所暗示的,它是基于JavaScript编程语言的一个子集,但它与语言无关,除了易于阅读和编写,更易于机器解析和生成。

相对于XML,它易于阅读。

JSON 对象

一个JSON对象,无非是括在大括号内的用逗号分隔的键值(名称/值)对。

javascript
{"name1":value1, "name2":value2 ...}

为了便于人们阅读和可视化,键值(名称/值)对经常垂直列出:

javascript
{
    "name1": value1,
    "name2": value2
}

键名(名称)应该使用双引号括起来,而值可以是下列任意一种形式:

JSON对象可以任意嵌套,以创建更复杂的对象:

javascript
{"user":
    {   "userid": 1900,
        "username": "jsmith",
        "password": "secret",
        "groups": [ "admins", "users", "maintainers"]
    }
}

有效的JSON格式

已定义的JSON语法(参看RFC 4627)中的介绍:

实现

JSON实现不是很严格,更多的要求客户端应用程序/解析器来执行JSON标准。像往常一样编写代码:

JSON有两个主要实现方式:

官方JSON语法规范

此实现将严格遵守RFC4627以上规范,并且不允许出现偏差。

JavaScript语法

This implementation follows the implementation of the Javascript programming language and as such allows for a few deviations from the official specification. For example:

(这个实现是Javascript编程语言的实现,因此允许与官方规范有偏差。例如:)

  1. 允许未引用键名,如{name: "John Doe" }
  2. 允许单、双引号引用键名,如 {'name': "John Doe", "language":'Pascal'}
  3. 允许最后一个成员后,跟随数组或对象,如 {"keywords":["if","begin","for",], "IDEs":["Lazarus","fpIDE","MSEide"],}

参看


From the Free Pascal wiki, page "JSON/zh CN", as it stood on 2015-07-17 after a change by FTurtle, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.