JSON vs XML
Here we are going to discuss the difference between JSON and XML with simple examples. In the last post, We have discussed some examples of json technology i.e what is JSON but here we will see JSON vs XML comparison.
Let's start, What is the difference between JSON and XML and what is the advantages of JSON over XML.
Let's start, What is the difference between JSON and XML and what is the advantages of JSON over XML.
JSON
- JSON stands for JavaScript Object Notation.
- JSON is easy to learn in comparison to XML.
- JSON is easy to read and write.
- JSON does not use any opening(<>) and closing(</>) tags.
- JSON is data-oriented technology.
- JSON is less secured than XML.
- JSON is light-weight in comparison of XML.
- JSON supports arrays.
- JSON supports text and number data types.
- JSON is less verbose than XML so it is faster to write programs in json.
JSON Example
This is simple example of json where will take student data with the help of json's object and array.
{"students" : [
{"name" : "shiv", "section" : "A", "city" : "delhi"},
{"name" : "john", "section" : "B", "city" : "mumbai"},
{"name" : "varun", "section" : "C", "city" : "keral"}
]
}
Now moving to XML
Now moving to XML
XML
- XML stand for eXtensible Markup Language.
- XML is not easy to learn in comparison of JSON.
- XML is less easy to read and write than JSON.
- XML uses opening(<>) and closing(</>) tags to define data.
- XML is documented-oriented technology.
- XML is more secured than JSON.
- XML is not light-weight than JSON.
- XML does not support arrays.
- XML supports text, number, chart, images, data types.
- XML is more verbose than JSON, so it is not faster to write programs than JSON.
XML Example
This is a simple example of XML where we will define some data of students in XML format. Let's convert above JSON example to XML.
For example:
<students>
<student>
<name>shiv</name>
<section>A</section>
<city>delhi</city>
</student>
<student>
<name>john</name>
<section>B</section>
<city>mumbai</city>
</student>
<student>
<name>varun</name>
<section>C</section>
<city>keral</city>
</student>
</students>
This was the differences between json and xml. Now let's discuss some similarities between JSON and XML.
For example:
<students>
<student>
<name>shiv</name>
<section>A</section>
<city>delhi</city>
</student>
<student>
<name>john</name>
<section>B</section>
<city>mumbai</city>
</student>
<student>
<name>varun</name>
<section>C</section>
<city>keral</city>
</student>
</students>
This was the differences between json and xml. Now let's discuss some similarities between JSON and XML.
Similarities Between JSON and XML
There are some similarities between json and xml and these are given below.
- JSON and XML both are open and simple technology.
- JSON and XML both are language - independent.
- JSON and XML both are self - describing i.e human readable.
- Internationalization is supported by JSON and XML because of both support unicode system.
We can convert json to xml, json to php, json to array and vice - versa.
Read More:
Difference Between HashSet and HashMap in Java.
Difference Between HashMap and Hashtable in Java.
Difference Between Abstract Class and Interface in Java.
Difference Between Array and Collection in Java.
Difference Between Constructor and Method in Java.
Difference Between C++ and Java.
Read More:
Difference Between HashSet and HashMap in Java.
Difference Between HashMap and Hashtable in Java.
Difference Between Abstract Class and Interface in Java.
Difference Between Array and Collection in Java.
Difference Between Constructor and Method in Java.
Difference Between C++ and Java.
Very informative
ReplyDeleteXML supports XPATH (for searching), XSLT (viewing & trasformation) & XSD to verify the schema of XML. It's far advanced than JSON but if you just want to use it for configuration then JSON is better but again JSON does not support adding comments, single quotes and few peculiar things.
ReplyDeleteThanks for sharing this informative blog java training in chennai
ReplyDelete