Comparison between JSON and XML

Source: Internet
Author: User

I have been familiar with JSON before and haven't made a deep Comparison Between XML and JSON. I saw a post today, but it's not bad. Let's take a look at it ~

Readability

The readability of JSON (Java Object Notation) 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 them.
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, JSON code can be written without tools, but it is not easy to write 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.