Difference Between JSON and XML

JSON and XML both of the technologies are used for representing data in a proper human understandable format and are independent of any computer language. In fact, these can be used with various languages on various platforms. But XML lacks behind due to some lack of acceptance and features. In comparison to JSON (JavaScript Object Notation), XML (Extensible Markup Language) seems more verbose. JSON is considered as a compact version of painting data in a human understandable format but may be difficult to understand at one glance by a newbie. Whereas it becomes easy to understand to by a newbie to go through an XML document. In this tutorial, you will see the significant points which bring differentiation among JSON and XML and make JSON more trending than XML.

Distinguishing XML with JSON

XMLJSON
XML (Extensible Markup Language).JSON (JavaScript Object Notation).
Slower in constructing an XML data representation format.Faster than XML for constructing data representation format.
Less simple to read than JSON.JSON is simpler to read than XML.
XML is a type of markup language.JSON is a means to characterize objects.
XML is a bit more flexible in detailing of data.JSON is not much flexible as compare to XML, but since it deals with objects, so it does not need much detail.
XML does not support the concept of arrayJSON supports representing data in the form of an array.
XML is more secure as compared to JSON.JSON seems less secured as compared to XML.
In case of parsing, the XML DOM (Document Object Model) allows to access and edit XML data.In case of parsing, the eval method of JavaScript's can parse JSON data.
XML data representing format is not self-describing.JSON data format is self-describing.

Differentiating JSON and XML Using a Code Snippet

Data representation in JSON Format:

{
  "employees": [
    {
      "name": "Alex",
      "location": "USA"
    },
    {
      "name": "Lalit",
      "location": "Canada"
    },
    {
      "name": "Deeksha",
      "location": "India"
    }
  ]
};

Same data representation XML Format:

<employees>
     <employee>
         <name> Alex </name>
         <location> USA </location>
     </employee>
     <employee>
         <name> Lalit </name>
         <location> Canada </location>
     </employee>
     <employee>
         <name> Deeksha </name>
         <location> India </location>
     </employee>
</employees>

Scroll Back to Top