JSON and XML comparison

Source: Internet
Author: User
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 (Standard ECMA-262 3rd edition-December 1999.
Comparison between JSON and XML
◆ Readability
The readability of JSON and XML is comparable. One side is the suggested syntax and the other side is the standard tag format, which makes it difficult to distinguish between the two.
◆ Scalability
XML is inherently highly scalable, and JSON is also available. There is nothing XML can be extended, and JSON cannot.
◆ Encoding difficulty
XML has rich coding tools, such as dom4j and JDOM, and JSON also provides tools provided by json.org. However, JSON encoding is much easier than XML, and JSON can be written without tools. Code But it is not easy to write the XML.
◆ Decoding difficulty
XML parsing takes into account the parent node of the child node, which is confusing, and the difficulty of JSON Parsing is almost 0. There is nothing to say about XML.
◆ Instance comparison
Both XML and JSON use structured methods to mark data. The following is a simple comparison.
Assume that a user data includes the user name, password, department, gender, and age.
It is represented as follows in XML:
<? XML version = "1.0" encoding = "UTF-8"?>
<User>
<Name> Zhang San </Name>
& Lt; password & gt; 123456 & lt;/password & gt;
<Department> Technical Department </Department>
<Sex> male </sex>
<Old> 30 </old>
</User>
JSON format:
{
"Name": "Zhang San ",
"Password": "123456 ",
"Department": "Technology Department ",
"Sex": "male ",
"Old": 30
}
Like XML, JSON is also text-based and uses unicode encoding, which is also readable. XML is more suitable for marking documents, while JSON is more suitable for data exchange processing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.