Main Difference between JSON and XML

Major difference between JavaScript object notation (JSON) and Extensible Markup language XML,JSON extended from JavaScript and developed by Douglas, XML extended from “Standard Generalized Markup Language and developed by W3C.


JavaScript object Notation Extensible Markup language.
Doesn’t support for Namespace Support for Namespace
Doesn’t support for comments
Support for comments
Cant convert to another format
Can convert to another format using XSLT
Its light-weighted because serialized format and so faster compare to XML
It’s not light-weighted Compare to JSON because its can have more character for same using in JSON
Its support data type include int,string and array also
It’s doesn’t support for data type ,so we go for parsed into particular data type.
Its text-based format
Its text-based format but having some set rules for encoding
Its better Usage for web service
Its better Usage for web configuration
Its Data oriented and easily mapped
Its Document oriented and not that much easily to mapping
No need to use start and end tag
Need to use start and end tag
It’s easier to parse from JavaScript
By using namespace we can implement for JavaScript
The JSON.parse() method parses a string as JSON, optionally transforming the value produced by parsing.





string to parse as JSON

prescribes how the value originally produced by parsing is transformed, before being returned

sample :

JSON.parse('"foo"'); // "foo"

JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]

Sample Code JSON :


"SalesPerson": [
"name": "Prabu",
"gender": "male">


"name": "Raju",
"gender": "male"
} ]



Sample Code XML:

//< SalesPerson >

// < SalesPerson >



// 23

//<\ SalesPerson >

/// < SalesPerson >


// <'gender>male


/// <\ SalesPerson >

// <\ SalesPerson >

Its not such a interface for getting direct access to a part in JSON data-structure
In XML, Using XPath, it is possible to get the direct access to a particular part of multiple parts of XML data- structure.
Using above xml sample code :
var document = new XPathDocument(@"sample.xml");

var navigator = document.CreateNavigator();

var books = navigator.Select("/SalesPerson/SalesPerson/name");


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: