# 学习JSON结构

2018年9月13日 / 16次阅读

JSON目前的标准文件是RFC8259

JSON can represent four primitive types (strings, numbers, booleans,
and null) and two structured types (objects and arrays).

JSON代表四种数据类型：字符串，数字，布尔（true or false），null；

JSON代表两个结构类型：对象（{}）和数组（[]），这两种结构可相互嵌套。

A string is a sequence of zero or more Unicode characters [UNICODE].
rather than a specific release. It is not expected that future
changes in the Unicode specification will impact the syntax of JSON.

An object is an unordered collection of zero or more name/value
pairs, where a name is a string and a value is a string, number,
boolean, null, object, or array.

An array is an ordered sequence of zero or more values.

The terms "object" and "array" come from the conventions of
JavaScript.

JSON's design goals were for it to be minimal, portable, textual, and
a subset of JavaScript.

The representation of numbers is similar to that used in most
programming languages. A number is represented in base 10 using
decimal digits. It contains an integer component that may be
prefixed with an optional minus sign, which may be followed by a
fraction part and/or an exponent part. Leading zeros are not
allowed.

A fraction part is a decimal point followed by one or more digits.

JSON text exchanged between systems that are not part of a closed
ecosystem MUST be encoded using UTF-8 [RFC3629].

    {
"Image": {
"Width":  800,
"Height": 600,
"Title":  "View from 15th Floor",
"Thumbnail": {
"Url":    "http://www.example.com/image/481989943",
"Height": 125,
"Width":  100
},
"Animated" : false,
"IDs": [116, 943, 234, 38793]
}
}

Its Image member is an object whose Thumbnail member is an object and
whose IDs member is an array of numbers.

This is a JSON array containing two objects:

    [
{
"precision": "zip",
"Latitude":  37.7668,
"Longitude": -122.3959,
"City":      "SAN FRANCISCO",
"State":     "CA",
"Zip":       "94107",
"Country":   "US"
},
{
"precision": "zip",
"Latitude":  37.371991,
"Longitude": -122.026020,
"City":      "SUNNYVALE",
"State":     "CA",
"Zip":       "94085",
"Country":   "US"
}
]

### 评论是美德

《学习JSON结构》有1条评论

• 麦新杰

比特币的交易数据也是JSON格式。 [ ]

Ctrl+D 收藏本页