Compare the Difference Between Similar Terms

Difference Between JSON and XML

Key Difference – JSON vs XML
 

Different computer systems and databases have various data formats. These data can be incompatible with each other. JSON and XML are two common formats to interchange data between different systems in the web. The key difference between JSON and XML is that JSON (JavaScript Object Notation) is a meta-language and XML (eXtensible Markup Language), as the name suggests, is a markup language. This article discusses the key features of JSON and XML and the similarities and differences between them.

CONTENTS

1. Overview and Key Difference
2. What is JSON
3. What is XML
4. Similarities Between JSON and XML
5. Side by Side Comparison – JSON vs XML in Tabular Form
6. Summary

What is JSON?

JSON stands for JavaScript Object Notation and helps to exchange data among various platforms. It is easy to read and write. JSON is mostly used with Asynchronous JavaScript (AJAX) and to develop RESTful web services. It can also be used with many languages such as Java, C, C++, Python. Some data types of JSON are Number, Boolean, String, Array, Object, Null.  JSON syntax is to use the key value pairs and data are separated by a comma.

Figure 01: JSON

Bellow is an example of a JSON Object.

{

“id” : “S001”,

“name” : “Ann”

}

What is XML?

XML is stands for “eXtensible Markup Language“. It has a tag-based syntax which is very similar to HTML, but it is not a replacement for HTML. HTML allows creating the structure of the web page. XML is the more general purpose. The main advantage of XML is that it allows programmers to create tags on his own. XML is a foundation of many web technologies. Some of them are XHTML, AJAX and Web Services. XHTML is HTML formatted  as XML syntax. AJAX is the  Asynchronous JavaScript and web services are using for developing API s. Some XML related technologies are XPath, XSLT,  XQuery.

XML can be read in client-side as well as server-side. It can be used in many languages. The programmer can use XML with C#, Visual Basic, Python, and  JavaScript. XML is used on various platforms such as Java platform, .NET platform, ios, Android. The main advantage of XML is that it can be used as a bridge between two different systems. For example, in a Bank, there can be an older computer system. XML can be used to connect it with a new system and to exchange data. Even though these two systems are completely different, it is possible to exchange data.

Figure 02: XML

XML syntax, using an example is as follows.

<student>

<id>S01</id>

<name> Ann </name>

</student>

XML is not suitable for large datasets. In that case, a database should be used. When the data get complex, it might be hard to read XML.

Bellow is an example of an array using JSON.

{ “students”: [

{ “id” : “S001”, “name” : “Ann”},

{ “id” :”S002″ ,”name” : “Peter”}

] }

Sample example using XML format.

<students>

<student>

<id> S001 </id> <name> Ann </name>

<id> S002 </id> <name> Peter </name>

</student>

</students>

What are the Similarities Between JSON and XML?

What is the Difference Between JSON and XML?

JSON vs XML

JSON is a  (JavaScript Object Notation)  is a text-based open standard for data interchanging. XML (eXtensible markup language) is a software-hardware independent format for data interchanging.
 Type
JSON is a meta-language. XML is a markup language.
Complexity
JSON is simple and easy to read. XML is more complicated.
 Orientation
JSON is data-oriented. XML is document-oriented.
Arrays
JSON supports arrays. XML does not support arrays.
File Extension
JSON file ends with .json extension. XML file ends with .xml extension.

Summary – JSON vs XML

JSON and XML are popular web technologies. JSON is lightweight, simple and easy to read. It is also faster. XML is more extensible and complicated. The difference between JSON and XML is that JSON is a meta-language and XML is a markup language. Generally JSON is preferred over XML because XML is hardened to parse than JSON. It is faster and easier than XML in AJAX related applications. JSON can be used as an alternative to XML.

Download the PDF Version of JSON vs XML

You can download PDF version of this article and use it for offline purposes as per citation note. Please download PDF version here Difference Between JSON and XML

Reference:

1.The point, Tutorials. “JSON Overview.”Tutorials Point, 15 Aug. 2017. Available here 
2.The point, Tutorials. “XML Overview.” Tutorials Point, 15 Aug. 2017.  Available here
3.TechGuyWeb. YouTube, YouTube, 5 Apr. 2017. Available here  

Image Courtesy:

1.’JSON’ by Linux Screenshots (CC BY 2.0) via Flickr
2.’Text-xml’By RRZEicons – Own work, (CC BY-SA 3.0) via Commons Wikimedia