Labels

Friday, March 10, 2017

JSON vs XML

XML was specified by W3C in the 90s, while JSON was specified by Douglas Cockford in 2002. 
JSON is a more lightweight data interchange format as compared to XML. It is basically built on two structures, collection of name/value pairs, and an ordered list of values.

JSON Over XML:
  • JSON can contain Integer, String, List, Arrays. Whereas XML is just nodes and elements that needs to be parsed into Integer, String and so on before it is used by your application.
  • XML uses a whole lot of opening and closing tags, JSON simply uses {} for objects, [] for arrays, and this makes it much more lightweight. 
    • In turn makes for faster processing and transmission, 
    • Even the serializing and deserializing is faster in JSON compared to XML
    • Easy Parsing - 
      • Because it contains no tags it makes it easier and faster to parse also, and takes less character to represent data.  
      • JSON does not need any additional code to parse, whereas XML needs DOM  and additional code for parsing.
  • JSON is smaller, faster and lightweight compared to XML. So for data delivery between servers and browsers, JSON is a better choice.
  • JSON is best for use of data in web applications from web services because of JavaScript which supports JSON.

XML Over JSON:
  • JSON is less secure because of absence of JSON parser in browser.
  • JSON is a better data exchange format. XML is a better document exchange format.
  • JSON has no easy wat to convert into another format HTML, SVG, plain text,comma-delimited. XML does it easily with XSLT Templates


Keep Blogging....

Arun Manglick