Let's learn java programming language with easy steps. This Java tutorial provides you complete knowledge about java technology.

Monday 30 October 2017

Difference Between JSON and XML

JSON vs XML

What is the Difference Between JSON and 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.


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


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.


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.

Share:

3 comments:

  1. XML 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.

    ReplyDelete
  2. Thanks for sharing this informative blog java training in chennai

    ReplyDelete

Facebook Page Likes

Follow javatutorial95 on twitter

Popular Posts

Translate