[Front-end development] JSON completely self-manual

JSON (JavaScript Object Notation, JS objects notation) is a lightweight data-interchange format. It is based on a subset of ECMAScript (European Computer Society norms established by js), using completely independent of the programming language of the text format to store and represent data. Simple and clear hierarchy make JSON an ideal data-interchange language. Easy to read and write, but also easy for machines to parse and generate, and effectively improve the efficiency of network transmission.

Details regarding JSON: JSON SSP (Photo Tutorial)

Brief History:

JSON (JavaScript Object Notation) is a lightweight data interchange format. Easy to read and write. It is easy for machines to parse and generate. It is based on JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999 a subset.

JSON is Douglas Crockford in 2001 to promote the use of data format, in 2005 - Year 2006 officially become the mainstream data formats, Yahoo and Google began widespread use JSON format at that time.

And XML comparison:

  • readability

JSON and XML can be described as comparable readability, while a simple syntax, while the standard form of a label, it is difficult winner.

  • Scalability

XML born with good scalability, JSON course, there are, nothing is XML and JSON can be extended but can not be extended. But JSON home game in Javascript, Javascript can store complex objects, xml has unparalleled advantages.

  • Coding difficulty

XML has a wealth of encoding tools, such as Dom4j, JDom etc., JSON tools are also provided. Without tools, the skilled developers believe that the same can quickly want to write xml document and JSON string, however, xml document to be a lot more characters on the structure.

  • Difficulty decoding

There are two ways of XML parsing:

First, analyzed by the document model, which is the parent tag index by a set of markers. For example: xmlData.getElementsByTagName ( "tagName"), but this is known in advance to be used in the case where the structure of the document can not be a common package.

Another method is to traverse node (document and childNodes). This can be achieved by recursive, but parsed data is still different forms, often can not meet the requirements in advance.

Any such extensible data structure must be so difficult to resolve them.

JSON is also true. If prior knowledge of the structure of JSON, JSON using data transfer is simply fantastic, you can write strong aesthetic readability very practical. If you are a pure foreground developers will love JSON. But if you're an application developer, I was not impressed, after all, is the real structured xml markup language for data transfer.

And if you do not know the structure of JSON parsing JSON away, then it is simply a nightmare. Time and effort do not say, the code will become redundant and excessively bureaucratic, and the result is less than satisfactory. But this does not affect the reception of many developers choose JSON. Because of the toJSONString json.js () you can see the character string structure of JSON. Of course, for those who do not often use this string, this is still a nightmare. After the usual JSON string of people see this, it's very clear structure of the JSON is much easier operation JSON.

These are only for analysis and data transfer xml JSON in Javascript. Javascript within the site, JSON, after all, is a home game, of course, the advantages far superior to xml. If stored in JSON Javascript compound object, but does not know its structure, I believe that many programmers are still the same cry of parsing JSON.
In addition to the above, JSON and XML there is another big difference is that the effective data rate. Case JSON as a data packet transmission format when more efficient because, unlike JSON as XML requires a rigorous closing tag, which allows the total amount of valid data packets than the greatly enhanced, thereby reducing data traffic the same under pressure transmission network.

Ali cloud developer community fully upgraded, one-stop experience, with more cool :( Ali cloud developer community home page )

Guess you like

Origin blog.51cto.com/14377691/2407335