Data transfer: JSON

Source: Internet
Author: User

Json:javascript object Notation,javascript objects represent methods, similar to XML, for storing and exchanging textual information.

1. JSON meaning

JSON is a lightweight text data interchange format;

JSON is independent of language;

JSON is descriptive and easy to understand.

JSON Example:

{"Orders": [     {"orderId": "1",     "ItemName": "Apple",         "origin":{               "province": " Hainan ",               " City ":" Haikou ",              " Detailed address ":" Haikou Naka Ward No. 35th "               }     ,    {" orderId ":" 2 " ,    " ItemName ":" Banana "    }  ]}
2. Comparison of JSON and XML

A, all can be transferred

B, JSON is plain text, XML is defined by tags; JSON data is smaller

C, JSON can be self-describing, better readability

D, JSON read and write faster

E, JSON can be parsed directly using the eval () method of JavaScript

3. JSON syntax

A, the data is stored in the form of Key/value to: mapping

"Name": "Lily"

B, two sets of data between the use, segmentation

"Name": "Lily", "Age": 18

C, curly braces Save the object

{"Name": "Lily",
"Addr": {
"Country": "China",
"City": "Beijing"
}
}

D, square brackets Save the array

{"Employees": [   "FirstName": "John", "LastName": "Doe" },   "firstName": "Anna", " LastName ":" Smith " },   " firstName ":" Peter "," LastName ":" Jones " }]}
4. Other data transmission formats

Protobug:google Open source serialization framework for internal use, support, and open source

Thrift:facebook developed a cross-language lightweight RPC messaging and data exchange framework

5. Several commonly used JSON libraries

Gson,fastjson,jackson,json-lib

Resources:

1. JSON Chinese official website http://www.json.org/json-zh.html

2, w3cschool-json:http://www.w3school.com.cn/json/json_eval.asp

3. Oschina-json Format tool: Http://tool.oschina.net/codeformat/json

4, json.cn:http://www.json.cn/json/wiki.html

5, the contrast between protobuf,json,xml,binary,thrift: http://blog.sina.com.cn/s/blog_406127500102uy6e.html

6, several common JSON library performance comparison: http://blog.csdn.net/vickyway/article/details/48157819

Data transfer: JSON

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.