Json is the world's most popular product within one year. json.org is a simple and effective data carrier. It is a method that uses strings to represent complex js objects. The backend is well-generated and the frontend is 0, next, I will introduce in detail the reasons for the popularity of json, which is why it has quickly become popular around the world within one year.
Now, I want to explain what JSON is. Let's talk about it. Here I want to analyze the reason why json is red. What do we get.
What is json? json.org is a simple and effective data carrier. json.org is a method that uses strings to represent complex js objects. It is well generated at the backend, and the front end is 0.
Its popularity is inseparable from the following reasons.
Persistence Trend:
Persistence is an important module introduced by javaEE5.
Php is inherently persistent. Every variable can be converted into serialize () and unserialize () and strings.
The most direct benefit of persistence is complex object storage and transmission. An important criterion for measuring the advantages and disadvantages of persistence mechanisms is efficiency.
WEB2.0 promotion:
Ajax has triggered the Web2.0 revolution, where x is xml. In ajax, xml is used as the carrier for data transmission in the front and back ends.
With the large-scale application of Web2.0, the efficiency of xml interpretation is undoubtedly exposed. xml is a very strictly prohibited structure, which causes any browser to load xml, the process of interpreting objects that javaScript can access is long. Json is the most concise object creation method supported by js by default. It is easy and pleasant to receive json objects. Therefore, json wins the game by efficiency on the stage of persistent data transmission.
JSON is easy to use.:
Why did some old Ajax technologies suddenly become popular because they are easy to use. To put it bluntly, since the advent of DHTML in the last century, the solution to brushless newest asynchronous data transmission is not just xmlHttpRequest. The hidden iframe can be completely done, and someone has always done the same. Ajax is highlighted in its ease of use. Therefore, the large-scale application of leading enterprises has caused Web2.0.
JSON is also easy to use. After JSON is used, I have replaced var obj = new Object (); var arr = [] with var obj = new Object (); var obj = new Array (). JSON is the most concise object definition method in js. For friends who have used eval () in js, there is basically no learning cost.
The popularity of tree structures represented by XML:
Xml is popular from the perspective of Data Structure, Because xml is a tree, the tree-like data structure is similar to xml, except for its own content nodes and the power of attribute nodes. DOM is a structure like this, And UML is a structure like this.
When we use data to describe the objective world, we find that the orders table in the relational data model is clumsy, and the tree structure is closer to thinking, this is also why people use freemind instead of notepad when making meeting records. Similarly, the efficiency of storing the tree using the partition table and recording parentid also gives the development space of LADP.
JSON is a way to define JS objects, while objects in JS are structured in a tree, therefore, JSON-defined objects are sufficient for describing data.
Several JSON-related topics:
Is JSON The Only Way to Solve xml efficiency problems?
Even though I do not know json, I use p to transmit data.
The backend uploads xmlHttp. responseText = 'to the foreground'
Lenel
';
And then use it when receiving data at the front-end.
The Code is as follows:
Function toDivElememnt (s ){
Var oDiv = document. createElement ("p ");
ODiv. innerHTML = s;
ODiv = oDiv. firstChild;
Return oDiv;
}
In this method, I didn't use js to explain json, but used DOM to explain HTML strings, which is quite natural. As mentioned above, HTML strings are also tree structures, after getting oDiv, I can access the attributes such as age and personid, which is quite efficient.
This is not my original work. It comes from my former Leader, Niu Ren, and Liang shiyiyou.
Will JSON replace XML?
No, we may do Ajaj In the Ajax field, but if XML can only do this, it is not XML :)
Isn't JSON used yet?
Don't fall behind Haha, the current mainstream background language are generated in the background, parse json api, specific how to use json, API where to look for a http://www.json.org look
What do we really get?
I still didn't summarize the details, but I think the language is the same. Isn't javaScript IOS C?