JSON vs XML

Similarities between JSON and XML:
  • JSON is plain text like XML
  • JSON is “self-describing”(human readable) and “self-understandable” as XML
  • JSON is hierarchical (values within values)
  • JSON can be parsed by JavaScript
  • JSON data can be transported using AJAX


Differences between JSON and XML:
  • No end tag like XML
  • Shorter than XML
  • Quicker to read and write when compare to XML
  • Can be parsed using built-in JavaScript functions like eval() and parse()
  • Uses arrays – Efficient for handling huge data
  • No reserved words

Why JSON?

JSON is faster and easier than XML when you are using it in AJAX web applications:

Steps involved in exchanging data from web server to browser involves:

Using XML
  • Fetch an XML document from web server
  • Use the XML DOM to loop through the document
  • Extract values and store in variables
  • It also involves type conversions
Using JSON

Fetch a JSON string
Parse the JSON string using eval() or parse() javascript functions


Author: admin

Share This Post On
  • journeycoder

    very nice, thanks
    should use json instead of xml

Pin It on Pinterest

Shares