You can see what JSON is and what JSON is.
JSON (Javascript Object Notation) is a lightweight data exchange format. Easy to read and write. It is also easy to parse and generate machines. It is based on a subset of Javascript Programming Language, Standard ECMA-262 3rd Edition-December 1999. JSON uses a completely language-independent text format, but it also uses a habit similar to the C language family (including C, C ++, C #, Java, Javascript, Perl, Python, and so on ). These features make JSON an ideal data exchange language.
The JSON concept is very simple, that is, the server directly generates Javascript statements, and the client directly uses the eval method to obtain this object after obtaining the object, which can save the parsing XML loss.
In XML format:
The Code is as follows:
1
Jackson
Http://www.jb51.net </url>
Welcome to Web.cn
2
Relkn
Http://www.jb51.net </url>
Web.cn focus on new Internet technologies
3
Kvogend
Http://www.jb51.net </url>
Jb51.net script home
Code:
The Code is as follows:
1
Jackson
Http://www.jb51.net </url>
Welcome to Web.cn
2
Relkn
Http://www.jb51.net </url>
Web.cn focus on new Internet technologies
3
Kvogend
Http://www.jb51.net </url>
Jb51.net script home
Use JSON:
The Code is as follows:
{Items :[
{
Id: 1,
Author: \ "Jackson \",
Url: \ "http://www.jb51.net \",
Content: \ "Welcome to Web.cn \"
},
{
Id: 2,
Author: \ "Relkn \",
Url: \ "http://www.jb51.net \",
Content: \ "Web.cn following new Internet technologies \"
},
{
Id: 3,
Author: \ "Kvogend \",
Url: \ "http://www.jb51.net \",
Content: \ "jb51.net script house \"
}
]};
Code:
The Code is as follows:
{Items :[
{
Id: 1,
Author: \ "Jackson \",
Url: \ "http://www.jb51.net \",
Content: \ "Welcome to Web.cn \"
},
{
Id: 2,
Author: \ "Relkn \",
Url: \ "http://www.jb51.net \",
Content: \ "Web.cn following new Internet technologies \"
},
{
Id: 3,
Author: \ "Kvogend \",
Url: \ "http://www.jb51.net \",
Content: \ "jb51.net script house \"
}
]};
JSON not only reduces the performance and compatibility issues caused by parsing XML parsing, but also is very easy to use for Javascript. It is convenient to retrieve data by traversing arrays and accessing object attributes, its readability is good, and it basically has the nature of structured data. I have to say that it is a good method. 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