Yes, because JSON is lightweight(less bandwidth intensive) and data oriented, so it's popularity is increasing and industries are preferring it over XML. And same time No, because there are some who still use XML because of it document oriented and schema focussed features. JSON is absolutely not superior to the XML every where,it is use-case dependent.However We have to say loudly and admit it JSON has an edge over XML.
All major "Amazon Product Advertising API" uses only XML and at the same time Facebook Graph API, Google Maps API, Twitter API, AccuWeather API, Pinterest API, Reddit API, Foursquare API uses JSON.
It has been long, over the years developer community divided over XML and JSON and it is still on with compromising logic, neither JSON and XML is superior over each other,it is the use case which drive organization to select JSON or XML.Remember a decade ago, XML was the hero of the town(first choice of data interchange format) and it eliminated all the shortcomings of SGML(Standard Generalized Markup Language) and played a vital role in evolution of web.But now JSON is dominating this data centric world and all major players extensively using it as privileged data format.
Why JSON is becoming more popular and organization first choice for data exchange?
Advantage of JSON over XML:-
If Facebook, Google ,Twitter and Foursquare is using JSON , then I do not think there is an iota of doubt about JSON feature richness over XML.What we need to understand what makes JSON so adorable when it comes to exchanging data over internet.
- JSON less verbose than XML: JSON documents are very straight forward and it is data focused instead of document oriented(XML documents). No extra ceremony is required other than { }( braces ) for objects , [ ] (brackets) for array and :(colon ) to separate key/value pair.However , XML requires little decoration to make a valid XML documents. It causes variation in size of the JSON document and XML document and in turn XML documents are more bandwidth intensive compared to JSON documents.So , transmission of JSON doc is faster compared to XML document. See below diagram to differentiate between XML and JSON doc. JSON doc is clearly light weight and less verbose than XML doc.
JSON Document sample | XML Document sample |
---|---|
{
"firstname" : "Nikhil", "lastname" : "Ranjan" "employeeId": "007" "designation": "SSE" "Organization": "XYZ" "skills":["java":"8/10","javaSctipt":"6 /10","python":"5/10"] } |
<Employee> <firstname>Nikhil</firstname> <lastname>Ranjan</lastname> <employeeId>007</employeeId> <designation>SSE</designation> <Organization>XYZ</organization> <skills> <java>8/10</java> <javaScript>6/10</javaSctipt> <python>6/10</python> </skills> </Employee> |
- JSON processing is faster than XML document: Apart from small JSON document compared to XML document for same data, it has been found that processing speed of JSON document is faster than XML document. JSON is estimated to parse up to one hundred times faster than XML.Along with processing , serialization and deserialization of JSON can be performed efficiently than XML document.
- Less System CPU resource utilization: In terms of CPU utilization, experiment conducted by Nurzhan, Michael ,Randall and Clemente suggest that JSON document takes less system CPU resource than XML document. It states that , JSON document takes more user CPU and less system CPU and overall resource consumption is less in JSON document. More user CPU time is better because it makes less system call and so less system CPU utilization. See below diagram for broader picture regarding transmission time and CPU utilization:
Transmission and CPU utilization analysis: XML vs JSON (Source: A Case Study by Nurzhan) |
- Natural support of data structure: JSON doc implicitly uses { } for object and [ ] for array
and it helps it to map directly to the corresponding data structures in various other languages. Another important feature that makes it compatible with Object oriented environment is that namespace of each fields is resolved in Object scope independently. Some people see JSON as deficient in namespace resolution. - JSON parsing support for all well known high level language : JSON is subset of JavaScript. JSON works seamlessly not only with JavaScript but also with Java, Python, C++, etc. There are various tools and third party library available to support JSON parsing efficiently. For java we have Gson, Genson, Jackson and FlexJson. Read how to do JSON parsing in java here.
- NoSQL and Big data: In this Web-centic world high volume of data (Google Map, Airlines info, etc) is transmitted over wires, so it was inevitable to opt some data transmission format which will be efficient and less bandwidth intensive.The most popular NoSQL databases like MongoDB and CouchDB relied on JSON as most preferred data transmission format and JSON playing key role in dealing with high volume of data efficiently. Along with these NoSQL
databases Amazon’s DynamoDB architecture is entirely based on REST/JSON and HBase(part of hadoop ecosystem) is mostly inclined towards JSON. - REST popularity as data transfer protocol: SOAP is XML based well known data transfer protocol. However, SOAP is very bulky and industries is shifting towards REST for exposing most of the resources(except sending some confidential data) and JSON has played a crucial role to make REST as industries first preference over SOAP. With popularity of REST many organization like Twitter and ForSquare has shifted their API base to support JSON only.Some are supporting both XML and JSON so as their major APIs like Google Cloud Storage, Linkedin API, Flickr API. Here is the complete list of software/web system using XML/JSON.
- Internet of things- Support for non computer device: It is expected that by 2020 the number of devices operable will explode from 20 million to 260 million and most of these devices will be using embedded system.Here lightweight JSON will be undisputed winner over XML.Future of JSON is bright.
- Ubiquitous JavaScript : Days are gone when javaScript was considered as front end scripting language. With evolution of javaScript in the form of Node.js (a server-side JavaScript framework), full stack development with javaScript became a very possible and it is highly compatible with JSON(Remember JSON is javaScript subset). With Node.js and MongoDB, it is very possible to create a light weight application and serve to wide range to device. JSON data interchange format has Ecma standards blessing too so it is also motivating Web application development community to adopt JSON as data exchange format.
Remember XML is not dead , So how do we appreciate XML in terms of its use ?
XML is document oriented (JSON is data oriented ) and XML makes its presence when we need represent document by giving semantic meaning to text through its tree-like structure.
and XML has natural ability to represent mixed content (JSON does not have it , however it can be achieved).
Read also:
References:
1.Comparison of JSON and XML Data Interchange Formats: A Case Study
2. A debate : XML vs JSON
Resources: How to covert XML to JSON
Tags:
JSON and XML
Sounds like a json purist!!!
ReplyDeleteHey thanks for posting such an informative blog. Please share more frequently so that people looking to gain more knowledge can actually gain some. Keep up the
ReplyDeletegood work.
Php training in Chennai||Php course in Chennai
Very nice piece of information, please keep updating and share your valuable information with us.
ReplyDeletehtml5 training in chennai|html5 training chennai|html5 course in chennai|html5 training institutes in chennai
Thanks for sharing this great article and i want to read some informative article about Informatica Read Json please share some article about Informatica
ReplyDeleteĐặt vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ bao nhiêu
chuyến bay về việt nam từ mỹ
mua vé máy bay từ nhật về việt nam
lich bay tu duc ve viet nam
vé máy bay từ canada về việt nam giá rẻ
vé máy bay từ hàn quốc sang việt nam
giá khách sạn cách ly ở hà nội