翻译_Understanding JSON(理解json)

Understanding JSON(理解json)

JSON (JavaScript Object Notation) is a lightweight syntax for exchangingdata that is designed to be understood easily by humans, and parsed easily bymachines. As the name implies, JSON is based on the JavaScript scripting language;however, JSON itself is completely language independent.

JSON(JavaScript对象表示法)是被设计为让人更易理解、让机器更易解释一个轻量级的数据交换语言。正如它的名字所意义的,Json 是基于JavaScript 脚本语言的,然而,它同样是一个完全独立的语言。

JSON is a popular notation for transmitting data through RESTful webservices. Numerous libraries for most programming languages allow easy parsingof JSON data, and many web frameworks now support producing JSON as responsedata. And because JSON has a smaller footprint than XML, it is ideal forconditions where network speeds are limited. For example, mobile devices oftenhave slower connections and so benefit from a smaller download.

在静态网页服务的数据传输中,Json是非常流行的。很多流行的程序语言中都有简单的解析Json数据(方法)的库,而且现在很多web框架都支持生成Json数据作为响应数据。这是因为Json比Xml更小,更适用于网络速度有限的状况。例如,移动设备通常(网络)连接速度较慢,所以用更小的下载(量)是更加有益的。

The official internet media type for JSON is application/json, and JSONfiles typically have a .json extension.

Json的官方互联网媒体类型是application/json,通常典型的Json文件会用.json作为扩展名。

Structure(结构)

JSON is defined by two basic structures.(Json被定义为两种基本结构)

  • Name/value pairs(“名字/值”对)
  • Ordered list of values(一组有序的值的列表)

A value can be any one of the following types, and these structures can benested:

这里的值(value)可以为下列任意类型,而且这些结构是可以被嵌套使用的:

  • String (Unicode)
  • Number
  • Boolean (true or false)
  • Array
  • Object
  • null (empty)

Examples(例子)

This object has three fields, where "name" is a string,"age" is a number, and "member" is a boolean.

这个对象有三组Name/value,name对应的value(即John)是String类型的;age对应的value(35)是数字类型的,member对应的value(false)是布尔类型的。

{

   "name": "John",

   "age":  35,

   "member": false

}

Arrays contain a list of values, which can be of any type. This object hastwo arrays; the "indexes" array contains numbers, and the"names"array contains strings.

数组包含一组value(值)的列表,这里的value是可以为任意的类型的。这个object对象有两个队列;"indexes"数组包括一组数字,"names"包含一组字符串。

{

   "indexes": [5, 10, 15, 20],

   "names": ["John", "Elizabeth","Mary"]

}

A contact card for an address book is a more complex example. This examplecombines many elements, including nested objects and arrays.

地址簿上的一个联系人卡片(信息)是一个更加复杂的例子,这个例子联合了更多的元素,包括嵌套对象和数组。

{

   "firstName": "John",

   "lastName": "Smith",

   "birthday": "1975-01-31",

   "spouse": {

       "firstName": "Mary",

       "lastName": "Smith"

    },

   "addresses": [

        {

           "description": "home",

           "street": "123 Peachtree Ln",

           "city": "Atlanta",

           "state": "GA",

           "postalCode": 30305

        },

        {

           "description": "work",

           "street": "456 Peachtree St",

           "city": "Atlanta",

            "state":"GA",

           "postalCode": 30305

        }

    ],

   "phoneNumbers": [

        {

           "description": "home",

           "number": "404-555-1234"

        },

        {

           "description": "mobile",

           "number": "678-555-1234"

        }

    ]

}

 

原文链接:http://spring.io/understanding/JSON


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值