This article brings you a comparison of the differences between json and XML. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
XML definition
Extensible Markup Language (XML) is a markup language used to mark electronic documents to make them structural. It can be used to mark data and define data. Type is a source language that allows users to define their own markup language.
JSON definition
JSON (JavaScript Object Notation) is a lightweight data exchange format that has good readability and is easy to write quickly. Data exchange between different platforms is possible. JSON adopts a highly compatible and completely language-independent text format, and also has behavior similar to C language habits (including C, C, C#, Java, JavaScript, Perl, Python, etc.). These properties make JSON an ideal data exchange language.
Advantages and Disadvantages of XML and JSON
Advantages of XML
A. The format is unified and compliant with standards;
B. Easy to integrate with other systems Remote interaction and data sharing are more convenient.
Disadvantages of XML
A.XML files are huge, the file format is complex, and transmission takes up bandwidth;
B.Both the server and the client need to spend a lot of code to parse XML , causing the server-side and client-side codes to become extremely complex and difficult to maintain;
C. The way of parsing XML between different browsers on the client side is inconsistent, and a lot of code needs to be written repeatedly;
D. Server-side and client-side Parsing XML takes more resources and time.
Advantages of JSON:
A. The data format is relatively simple, easy to read and write, the formats are compressed, and takes up little bandwidth;
B. Easy to parse, client JavaScript can simply read JSON data through eval();
C. Supports multiple languages, including ActionScript, C, C#, ColdFusion, Java, JavaScript, Perl, PHP, Python, Ruby and other server-side languages. Convenient for server-side parsing;
D. In the PHP world, PHP-JSON and JSON-PHP have already appeared. It is preferable to directly call the program after PHP serialization. PHP server-side objects, arrays, etc. can directly generate JSON format. Convenient for client access and extraction;
E. Because the JSON format can be directly used by server-side code, it greatly simplifies the code development of server-side and client-side, and the task remains unchanged and is easy to maintain.
Disadvantages of JSON
A. It is not as popular and widely used as XML format, and it is not as versatile as XML;
B.JSON format is currently used in Web Service Promotion in China is still in its infancy.
XML definition
Extensible Markup Language (XML) is a markup language used to mark electronic documents to make them structural. It can be used to mark data and define data. Type is a source language that allows users to define their own markup language.
JSON definition
JSON (JavaScript Object Notation) is a lightweight data exchange format that has good readability and is easy to write quickly. Data exchange between different platforms is possible. JSON adopts a highly compatible and completely language-independent text format, and also has behavior similar to C language habits (including C, C, C#, Java, JavaScript, Perl, Python, etc.). These properties make JSON an ideal data exchange language.
Advantages and Disadvantages of XML and JSON
Advantages of XML
A. The format is unified and compliant with standards;
B. Easy to integrate with other systems Remote interaction and data sharing are more convenient.
Disadvantages of XML
A.XML files are huge, the file format is complex, and transmission takes up bandwidth;
B.Both the server and the client need to spend a lot of code to parse XML , causing the server-side and client-side codes to become extremely complex and difficult to maintain;
C. The way of parsing XML between different browsers on the client side is inconsistent, and a lot of code needs to be written repeatedly;
D. Server-side and client-side Parsing XML takes more resources and time.
Advantages of JSON:
A. The data format is relatively simple, easy to read and write, the formats are compressed, and takes up little bandwidth;
B. Easy to parse, client JavaScript can simply read JSON data through eval();
C. Supports multiple languages, including ActionScript, C, C#, ColdFusion, Java, JavaScript, Perl, PHP, Python, Ruby and other server-side languages. Convenient for server-side parsing;
D. In the PHP world, PHP-JSON and JSON-PHP have already appeared. It is preferable to directly call the program after PHP serialization. PHP server-side objects, arrays, etc. can directly generate JSON format. Convenient for client access and extraction;
E. Because the JSON format can be directly used by server-side code, it greatly simplifies the code development of server-side and client-side, and the task remains unchanged and is easy to maintain.
Disadvantages of JSON
A. It is not as popular and widely used as XML format, and it is not as versatile as XML;
B.JSON format is currently used in Web Service Promotion in China is still in its infancy.
related suggestion:
Comparison of the differences between substring&substr&slice in js
A brief introduction to the usage of new operator in js (code)
The above is the detailed content of Comparison of the differences between json and XML. For more information, please follow other related articles on the PHP Chinese website!