A list of differences between JSON and XML are given below.
|
No. |
JSON |
XML |
|
1) |
JSON stands for JavaScript Object Notation. |
XML stands for eXtensible Markup Language. |
|
2) |
JSON is simple to read and write. |
XML is less simple than JSON. |
|
3) |
JSON is easy to learn. |
XML is less easy than JSON. |
|
4) |
JSON is data-oriented. |
XML is document-oriented. |
|
5) |
JSON doesn’t provide display capabilities. |
XML provides the capability to display data because it is a markup language. |
|
6) |
JSON supports array. |
XML doesn’t support array. |
|
7) |
JSON is less secured than XML. |
XML is more secured. |
|
8) |
JSON files are more human readable than XML. |
XML files are less human readable. |
|
9) |
JSON supports only text and number data type. |
XML support many data types such as text, number, images, charts, graphs etc. Moreover, XML offeres options for transferring the format or structure of the data with actual data. |
Similarities between JSON and XML
- Both are simple and open.
- Both supports unicode. So internationalization is supported by JSON and XML both.
- Both represents self describing data.
- Both are interoperable or language-independent.
Why JSON is Better Than XML
XML is much more difficult to parse than JSON.
JSON is parsed into a ready-to-use JavaScript object.
For AJAX applications, JSON is faster and easier than XML:
Using XML
- Fetch an XML document
- Use the XML DOM to loop through the document
- Extract values and store in variables
Using JSON
- Fetch a JSON string
- JSON.Parse the JSON string