Brief Introduction to json

Source: Internet
Author: User

Introduction
We know that AJAX technology can make every request faster. For each request, the returned data is not the whole page, but also the data to be returned. AJAX usually returns XML format data, and then parses and renders the XML format data through complicated JavaScript scripts on the client.
JSON (read Jason) is used to make the data format a standard, which is simpler to be parsed by JavaScript.

Advantages
1. lightweight data exchange format
2. easier reading and writing
3. Easy machine resolution and generation
4. JSON parsing through eval () function in JavaScript
5. JSON supports multiple languages. Including: ActionScript, C, C #, ColdFusion, E, Java, JavaScript, ML, Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Lua.

Syntax
JSON syntax is a protocol used to transmit and generate data. It is similar to the C language, so it is easily parsed by the C language.
Object: the object is included {}
Attribute: the Key-Value pair is used. Use commas to separate attributes. String: value
Array: The array is stored between [] [elements]
Elements: separated by commas
Value: The value can be a string, number, object, array, true, false, or null.
Example:
JSON
[
{
Name: "Michael ",
Email: 17bity@gmail.com ",
Homepage: "http://www.jialing.net"
},
{
Name: "John ",
Email: john@gmail.com ",
Homepage: "http://www.jobn.com"
},
{
Name: "Peggy ",
Email: peggy@gmail.com ",
Homepage: "http://www.peggy.com"
}
]


In fact, google maps does not use XML to transmit data, but uses the JSON scheme.
Another advantage of JSON is "cross-origin". For example, you can use
<Script type = "text/javascript" src = "http://www.yyy.com/some.js">
This means that you can transmit information across domains. However, XMLHttpRequest cannot obtain cross-origin information, which is restricted by the security nature of Javascript.

Can JSON completely replace XML? Of course not. The reason is the advantage of XML: versatility. It is not easy for the server to generate Javascript code with the correct syntax. This mainly happens in a large system, where different developers are working on the server and the client.

Related Article

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.