Site Loader
Get a Quote
difference between JSON and XML
difference between JSON and XML

JSON Tutorial: JSON and XML


JSON and XML:  Hi readers, in this JSON Tutorial we have explained the JSON and XML. As both, JSON and XML are mainly used to exchange data but we find some of the differences between them which make JSON more powerful and advantageous over XML. Here in this tutorial first we list out the differences between JSON and XML and further we explain some of the similarities as well. And then the Simple example of JSON File and XML File containing same data makes you more clear between JSON and XML.

Difference Between JSON and XML:


  • 1)  JSON is developed by Douglas Crockford and XML is developed by W3C(World Wide Web Consortium)
    2)  JSON Stands for JavaScript Object Notation whereas XML stands for eXtensible Markup Language.
    3)   JSON is extended from JavaScript whereas XML is extended from SGML(Standard Generalized Markup Language)
    4)   JSON is data oriented whereas XML is document oriented.
    5)   JSON is faster and easier than XML.
    6)   JSON store the data in KEY/VALUE format whereas XML store data using tags i.e start and end tag both are compulsory.
    7)   JSON Syntax is lighter than XML or we can say JSON is light-weighted as it has serialized format whereas XML is not so light-weighted.
    8)   JSON is the text-based format and it is standard of interchanging data i.e. Humanly readable whereas XML is Markup Language having format which contains some set of rules like every start tag must have an end tag, etc. i.e both human and machine readable.
    9)   JSON supports only text and numeric datatype whereas XML supports all type of datatype including text, numeric, image,           chart, graphs etc.
    10)  JSON also support array and native objects whereas XML has no direct support for array and objects. Like, through a mixed use of attributes and elements XML can support native objects.
    11)  JSON does not support Comments whereas XML supports Comments.
    12)  JSON also does not have any support for Namespaces whereas XML supports Namespaces.

 Similarities between JSON and XML:


  •     1)  Both JSON and XML are used to exchange data over servers.
        2)  Both are Language-Independent, self-describing and self-understandable.
       3)  Both are open and human-readable.
             4)  Both supports interoperability feature.

Simple Example of the File format of JSON and XML:


Here in this simple example we have stored some information of student using  .json and .xml file.

Both files contain the same data but in a different format. So that one can easily differentiate between JSON & XML file Format.

info.json


{ "studentId": "SJ011MS",
 "student": {
 "name": "Deepak Singh",
 "gender": "Male",
 "age": "27",
 "address": {
 "city": "varanasi",
 "state": "Uttar Pradesh",
 "pincode": "221001"
 }
 },
 "course": "B.S.c",
 "section": "B"
 
}

info.XML


<?xml version="1.0"?>
<student>

<studentId>SJ011MS</studentId>
<name>Deepak Singh</name>
<gender>Male</gender>
<age>27</age>

<address>
<city>varanasi</city>
<state>Uttar Pradesh</state>
<pincode>221001</pincode>
</address>

<course>B.S.c</course>
<section>B</section>

</student>


                                                                                                            

Post Author: TechieFlair

Leave a Reply

Your email address will not be published.