什么是JSON? [英] What is JSON?

查看:116
本文介绍了什么是JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是JSON?

推荐答案

JSON(JavaScript对象表示法)是一种轻量级的数据交换格式.人类很容易读写.机器很容易解析和生成.它基于JavaScript编程语言(标准ECMA-262第三版-1999年12月)的子集.JSON是一种文本格式,它完全独立于语言,但是使用C语言家族(包括C语言)的程序员熟悉的约定. ,C ++,C#,Java,JavaScript,Perl,Python等.这些属性使JSON成为理想的数据交换语言.

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

参考号: json.org

对象是一组无序的名称/值对.对象以{(左括号)开始,以}(右括号)结束.每个名称后面都带有:(冒号),名称/值对之间以,(逗号)分隔.

An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).


(来源: json.org )


(source: json.org)

数组是值的有序集合.数组以[(左括号)开头,以](右括号)结尾.值之间以,(逗号)分隔.

An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).


(来源: json.org )


(source: json.org)

可以是带双引号的字符串,也可以是数字,也可以是true或false或null,或者是对象或数组.这些结构可以嵌套.

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.


(来源: json.org )


(source: json.org)

字符串是零个或多个Unicode字符的集合,使用反斜杠转义符将其括在双引号中.字符表示为单个字符串.字符串非常类似于C或Java字符串.

A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.


(来源: json.org )


(source: json.org)

数字非常类似于C或Java数字,只是不使用八进制和十六进制格式.
(来源: json.org )

A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.
(source: json.org)

这里是一个例子:

{
    "menu": {
        "id": "file",
        "value": "File",
        "popup": {
            "menuitem": [{
                "onclick": "CreateNewDoc()"
            }, {
                "value": "Open",
                "onclick": "OpenDoc()"
            }, {
                "value": "Close",
                "onclick": "CloseDoc()"
            }]
        }
    }
}

在XML中,本来应该是这样:

And in XML the same thing would have been:

<menu id="file" value="File">
  <popup>
    <menuitem value="New" onclick="CreateNewDoc()" />
    <menuitem value="Open" onclick="OpenDoc()" />
    <menuitem value="Close" onclick="CloseDoc()" />
  </popup>
</menu>

参考号: json.org

希望您现在了解什么是JSON.

Hope you now get an idea of what is JSON.

这篇关于什么是JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆