JSON detailed __json

Source: Internet
Author: User

What is JSON. JSON (JavaScript Object notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy to machine parse and generate. It is based on a subset of JavaScript (Standard ECMA-262 3rd edition-december 1999). JSON uses a completely language-independent text format, but it also uses a family of C-language (c, C + +, C #, Java, JavaScript, Perl, Python, and so on). These features make JSON an ideal data exchange language. JSON-built structure:

1. Collection of name/value pairs (A collection of name/value pairs). In different languages, it is understood as objects (object), records (record), structure (struct), dictionaries (dictionary), hash tables (hash table), a list of keys (keyed list), or associative arrays (associative Array).

2. List of values (an ordered list of values). In most languages, it is understood as an array.

These are common data structures. In fact most modern computer languages support them in some way. This makes it possible for a data format to be exchanged between programming languages that are also based on these constructs. the exact form of JSON

1, the object is an unordered "' name/value ' Pair" collection. An object begins with "{" and ends with "}". Each "name" is followed by a ":", "' Name/value ' pair", separated by "."

2. An array is an ordered set of values (value). An array ends with "[" Beginning, "]". Values are delimited by using the ",".

3. Values (value) can be strings (string), numeric values (number), True, False, NULL, objects (object), or arrays (array) enclosed in double quotes. These structures can be nested.

4. A string is a collection of any number of Unicode characters enclosed by double quotes, which is escaped using italics. A character (character) is a separate string (Characeter string). the comparison of JSON and XML

readability

JSON and XML are comparable in readability, with the suggested syntax on one side and the canonical label form, which is difficult to distinguish between the winners and losers.

Scalability

XML is inherently extensible, of course, and there is no XML that can be extended, JSON cannot.

Coding Difficulty

XML has a wealth of coding tools, such as dom4j, Jdom and so on, JSON also has the tools provided by json.org, but the JSON encoding is significantly easier than XML, even if you can write JSON code without the help of tools, it's not easy to write XML.

Decoding difficulty

The parsing of XML takes into account the parent node of the child node, making people dizzy, and JSON parsing is almost 0. This XML loser is really nothing to say.

instance Comparison

Both XML and JSON use structured methods to mark data, and here's a simple comparison.

It is assumed that a user's data includes user name, password, department, gender, and age.

The following is represented in XML:

Tom

123456

Technical Department

Man

30

The following is represented in JSON:

{

"Name": "John",

"Password": "123456",

"Department": "Technology department",

"Sex": "Male",

"Old": 30

}

Like XML, JSON is text-based, and they all use Unicode encoding, as well as readability. XML is better suited for tagging documents, but JSON is more appropriate for rows of data exchange processing.

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.