A brief introduction to json_json
- WBOYOriginal
- 2016-05-16 19:03:371145browse
Introduction
We know that AJAX technology can make every request faster. For every request, not the entire page is returned, but only the data that needs to be returned. Usually AJAX returns data in XML format, and then parses and renders these XML format data through complex JavaScript scripts on the client side.
JSON (read Jason) is intended to make the data format a standard and easier to be parsed by JavaScript.
Advantages
1. Lightweight data exchange format
2. Easier for people to read and write
3. Easy for machine parsing and generation
4 , Ability to parse JSON through the eval() function in JavaScript
5. JSON supports multiple languages. Includes: ActionScript, C, C#, ColdFusion, E, Java, JavaScript, ML, Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Lua.
Syntax
JSON syntax is a protocol for transmitting and generating data. It is very similar to the C family language, so it is easily parsed by the C family language.
Object: The object is contained between {}
Attributes: Represented by Key-Value pairs. Use commas to separate attributes. string : value
Array: Array is stored between [] [elements]
Element: Elements are separated by commas
Value: Value can be string, number, object, array, true, false, 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 solution. Another advantage of
JSON is "cross-domain". For example, it is completely feasible for you to use
<script> <BR> in a web page, which means you can pass information across domains. However, cross-domain information cannot be obtained using XMLHttpRequest, which is limited by the internal security properties of Javascript. <br><br>Can JSON completely replace XML? Of course not, the reason lies in the advantage of XML: versatility. It is not easy to generate grammatically qualified Javascript code on the server side. This mainly happens in relatively large systems where there are different developers on the server side and client side.</script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn