Understanding JSON in detail

Source: Internet
Author: User

1. What is JSON?

Full Name: JSON (Javascript Object Notation)

An object syntax introduced by JavaScript after IE7.

JSON is a lightweight data interchange format and is a standalone language.

Function: Typically used for service-side transmission of data to a page.

Advantages: Easy to understand. Click here to view JSON and XML comparison http://www.cnblogs.com/SanMaoSpace/p/3139186.html

Json.jar Download: http://download.csdn.net/download/qq_31708763/9957838

2.JSON Syntax Rules:

Data is a key-value pair K:V

The data is separated by commas,

Curly braces Save Object object: {}

Block save Array []
Property : Property name : value , separated by commas between many pairs of attributes and values.

Multiple objects, which can be organized using a JSON array ,

JSON array :

[{id:1,city:xxx},{id:2,city:xxx},{id:3,city:xxx}]

var arr=[{

Id:1,

City: "Beijing"

},

{

Id:2,

City: "Shanghai"

},

{

Id:3,

City: "Guangzhou"

}];

How do I convert a string in json form to a JSON object?

Use the eval () function

var obj = eval ("(" + ")")

You can also var obj = Json.parse (arr);

Click here to view the city Cascade instance http://blog.csdn.net/qq_31708763

Understanding JSON in detail

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.