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