首页 » InfoTech »

学习JSON结构

2018年9月13日 / 11次阅读

打开支付宝首页,搜索“529018372”,即可领取红包!可重复领。

系统间数据交换,大量广泛地使用JSON格式。

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].
Note that this citation references the latest version of 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].

开放的系统间交换JSON数据,必须使用UTF-8编码

好了,现在看几个JSON的实例,体会其结构。

这是一个JSON对象:

    {
        "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.

下面是一个JSON数组的示例:

This is a JSON array containing two objects:

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

一个数组里面包含了两个数据对象。

本文链接:http://www.maixj.net/ict/json-18892
云上小悟 麦新杰(QQ:1093023102)

相关文章

评论是美德

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

无力满足评论实名制,评论对非实名注册用户关闭,有事QQ:1093023102.

  • 麦新杰

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


前一篇:
后一篇:

栏目精选

云上小悟,麦新杰的独立博客

Ctrl+D 收藏本页

栏目


©Copyright 麦新杰 Since 2014 云上小悟独立博客版权所有 备案号:苏ICP备14045477号-1。云上小悟网站部分内容来源于网络,转载目的是为了整合信息,收藏学习,服务大家,有些转载内容也难以判断是否有侵权问题,如果侵犯了您的权益,请及时联系站长,我会立即删除。

网站二维码
go to top