The difference between XML and JSON

Source: Internet
Author: User
Tags php server

Defined

Definition of 1.XML

The Extensible Markup Language (extensible Markup Language, XML), which is used to tag electronic files with a structured markup language that can be used to tag data, define data types, is a source language that allows users to define their own markup language. XML uses the DTD (document type definition) document type definition to organize the data, a unified format, cross-platform and language, and has long been recognized as a standard in the industry.
XML is a subset of standard Generalized Markup Language (SGML) and is ideal for web transport. XML provides a unified approach to describing and exchanging structured data that is independent of the application or vendor.

Definition of 2.JSON

JSON (JavaScript Object Notation) is a lightweight data interchange format with good readability and easy-to-write features. Data exchange between different platforms is possible. JSON uses a very high compatibility, completely independent of the language text format, but also has a similar to the C language habits (including C, C + +, C #, Java, JavaScript, Perl, Python, etc.) the behavior of the system. These features make JSON an ideal data exchange language.

Difference

1. Differences in coding

JSON is more readable and less redundant, and XML is better suited for tagging documents. The JSON Web site provides a strict description of the JSON syntax, just a short description. JSON is more suitable for data exchange processing.

2. The difference between encoding readability

XML has obvious advantages, after all, the human language is closer to such a descriptive structure. JSON reads more like a block of data, which is more puzzling to read. However, we read the puzzling language, which is precisely suitable for machine reading.

Advantages and disadvantages of XML:

1. Uniform format, conforms to the standard
2. Easy to interact with other systems remotely, data sharing is more convenient
3. Call an existing service that uses XML as a transport.
4. Use XSLT to convert XML dynamically. This is an ideal feature in an enterprise service Bus (ESB) scenario.

Disadvantages:

1. xml file format file is large, complex format, transmission consumption bandwidth
2. Both the server side and the client need to spend a lot of code parsing XML, regardless of the server side and client code becomes unusually complex and not easy to maintain
3. Client-side parsing of XML between different browsers is inconsistent, and many code needs to be written repeatedly
4. Server side and client parsing XML spend resources and time

The pros and cons of JSON

Advantages:

1. Data format is simple, easy to read and write, the format is compressed, occupy small bandwidth, browser parsing fast
2. Easy to parse the language, client-side JavaScript can easily read the JSON data through eval ()
3. Friendly structure, support multiple languages, including ActionScript, C,c#,coldfusion,java,javascript,per,php,python,ruby and other languages server-side language, convenient for server-side analysis
4. In the PHP world, there are already Php-json and json-php appear, easy to invoke after the PHP serialization program, PHP server-side objects, arrays and so on can directly raw JSON format, convenient for client access extraction
5. Because the JSON format can be used directly for server-side code, greatly simplifies the server-side and client code development, but the completion of the task is not changed, and easy to maintain
6. Fairly stable. The additional content of the JSON becomes a superset

Disadvantages:

1. There is no XML format so popularized and widely used, without XML so universal
2. The JSON format is currently promoted in the Web service as an initial stage

The difference between XML and JSON

Related Article

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.