JSON data vs XML data

JSON data vs XML data

Hello everyone, in this article we are going to make a comparisation between JSON and XML. We will explain what json and xml and after compare them.

Let's start to compare now.

What is XML?

XML is a markup language which is using to keep and transfer datas. Stands for eXtensible Markup Language Very basic unit of XML is known as element XML is case sensitive language. It means when you try to specify the element must be careful about element names. File extention of XML files is .xml. In XML you can create custom named elements and you can organize them according to your requires. XML is using for transferring data over the internet.

Below you can see the example of XML: <?xml version="1.0" encoding="UTF-8"?> <aircraft> <brand>Airbus</brand> <model>A330</model> <owner>Burak Airlines</owner> </aircraft> <aircraft> <brand>Boeing</brand> <model>B777</model> <owner>Burak Airlines</owner> </aircraft>

What is JSON?

The word JSON is standing for JavaScript Object Notation. It is fast way to keep and transfer data. JSON generally using for transferring data between client side and server side of an application. JSON is working with key-value pairs and easy to understand language.

JSON has data, array and object. Below I will show examples about these terms:

JSON Data:


"firstname":"Burak Hamdi"

JSON Object example is:


{
     "firstname":"Burak Hamdi",
     "surname":"TUFAN", 
     "website":"thecodeprogram.com" 
}

JSON Array Example is:


"aircrafts":[
    {"brand":"Airbus", "model":"A320"},
    {"brand":"Airbus", "model":"A330"},
    {"brand":"Boeing", "model":"B737"},
    {"brand":"Boeing", "model":"B777"},
]

Now we know What JSON and XML. It is time to compare them.

JSON XML
JSON object has a type as data, object or array XML data is typeless
JSON types: string, number, array, Boolean string is the only data type
Data is readily accessible as JSON objects XML data needs to be parsed.
JSON is supported by most browsers. Cross Browsers can parse the XML
Reading value is easy Reading value is difficult
Supported by many Ajax toolkit Not fully supported by Ajax toolkit
Native support for object in popular programming languages. The object has to be express by conventions - mostly missed use of attributes and elements.
Supports only UTF-8 encoding. Supports various encoding.
It doesn't support comments. It supports comments.

Advantages of using JSON

  • All browsers support JSON
  • Reading and writingis easy.
  • Readible Syntax
  • Javascript and Java parse it Nativelly
  • It is using in many Java Script based Frameworks
  • You can save it to the databse as text and after reading from database ypou can convert to JSON data.

Advantages of using XML

  • Transforming datas are easy.
  • You can seperate the data from HTML in XML.
  • It has customizable elements.

That is all in this article.

Have a good data transferring.

Burak Hamdi TUFAN


Tags


Share this Post

Send with Whatsapp

Post a Comment

Success! Your comment sent to post. It will be showed after confirmation.
Error! There was an error sending your comment.

Comments

    There is no comment. Be the owner of first comment...