Difference between XML and JSON

XML

JSON

XML is more verbose than JSON

JSON is less verbose than XML

XML is tree based

JSON’s data structure is a map

Xml was designed to carry or store data.

JSON was designed to carry and display data.

Xml is based on SGML

JSON is text based following Java Script Object Notation.

Xml supports namespace

JSON doesn’t support any namespace

Xml supports comments

JSON doesn’t supports comments.

Xml supports Start and End Tags

JSON doesn’t support End tags

Xml doesn’t support array

JSON supports array

XML has to be parsed with XML parser.

JSON can be parsed by a standard JavaScript function.

Parsing process -

Fetch an XML document

Use the XML DOM to loop through the document

Extract values and store in variables

Parsing process -

Fetch a JSON string

Parse the JSON string

 

Xml parsing is slower since DOM parsing is slower.

JSON Parsing is faster since its based on format of Javascript object.

Xml message validation is supported using XML schemas

JSON validation is supported using JSON Schema, but it is not comprehensive compared to XSD

Xml can be easily transformed using XSLT

No Transformation is available.

No comments: