Json - XML vs JSON

Json - XML vs JSON

Advantage of JSON :



Simple Syntax.

Complex nested elements.

Support for data types such as integers, strings, lists, arrays.

Contains just nodes, its elements and data.

Easy to use with JavaScript.

No support for JavaScript.

Data Parsing cost is very less.

Parsing is a tedious task.

Serialization/Deserialization is faster.

Serialization/Deserialization is tough task with XML.

JSON provides instant data lookup facility.

XML does not provide instant data lookup facility.

JSON is best for its size and ease of use in data consumption in web applications using web services.

XML is a fair bit longer document.

JSON is good for data exchange format.

XML is better for document exchange format.

JSON supports Unicode format for internationalization support.

XML too support Unicode.

JSON is based on arrays / records and hence there is no need for translation.

XML needs data translation from element form to a document structure.

With JSON structure, data can be fetched easily with iterations.

XML data structure is difficult to navigate for data using XPath.

JSON is not suited for configurations file.

XML is the best format for configurations file.

JSON does not audio or images or other large binary payloads.

XML extends its support for text, numbers, audio, Java applets or even ActiveX components.

JSON is not extensible.

XML is extensible, as its name suggests.

JSON format is very hard and not so human readable.

XML is the best choice in case of human readable format.

Format changes are impossible with JSON.

Format changes for XML data is made simpler with XSLT templates. Even it can be converted into JSON format.

JSON is less secure because of absence of JSON parser.

For security reasons on the browser side XML is better choice.

To summarize :

  • JSON is a good choice for data delivery between servers and browser clients.
  • XML is a good choice for storing configuration information.
  • On Browser Side: JSON is parsed faster and it eases the data retrieval task from JavaScript object. Hence JSON suits better for browsers.
  • Server Side: XML acts as a better choice for data querying and format changes.
  • XML is the only choice to extract data from database.
  • Below is sample JSON and XML data containing two employees’ records.

Sample JSON Data :

    {"firstName":"Arun", "lastName":"J"}, 
    {"firstName":"Venkat", "lastName":"J"}

Sample XML Data :