Difference Between XML and JSON

Difference Between XML and JSON

Before explaining the Difference Between XML and JSON, let defines XML and JSON one by one first. Both XML and JSON files are human-readable and XML parsers and JSON parsers are available in most programming languages.

What is XML?

XML is an Extensive Markup Language primarily designed to carry data. It is a W3 recommendation. It is a markup language that defines a set of rules for encoding documents in a format that is both machine-readable and human-readable.

Example of XML

This note is a note to Binod from Anita, stored as XML:

<body>Hello Binod, I hope you are well</body>

What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight language independent data-interchange format based on JavaScript. It is self-describing easy to understand that stores human-readable text to transmit data objects from server to web pages.

JSON Example
This example defines a student object: an array of 3 student records (objects):


{“firstName”:”Bikash”, “lastName”:”Rai”},
{“firstName”:”Prabin”, “lastName”:”Dhungana”},
{“firstName”:”Nawaraj”, “lastName”:”Basnet”}

Difference Between XML and JSON

It stands for Extensive Markup Language. It stands for JaveScript Object Notation.
It is derived from SGML(standard generalized markup language). It is based on the JaveScript language.
It is a markup language that uses tags structure to represent data items. It is a way of representing objects.
It supports namespace. It does not provide any supports for namespace.
It does not support arrays. It supports arrays.
It is comparatively secured than JSON. It is less secure than XML.
It supports comments. It does not support comments.
It used start and end tags. It does not use end tag.
Its documents are comparatively difficult to read. Its files are very easy to read as compared to XML.

XML and JSON which is better?

JSON (Javascript object notation) has become a popular alternative to XML for various reasons. It is more lightweight than XML. XML uses more words than necessary while JSON is faster compared to XML as JSON has a more compact style.

JSON makes significant improvements in RESTful APIs while working with complex systems. So, comparatively, JSON is better than XML.

Leave You Comment