Battle of data formats: JSON vs XML

Aug 05, 2014 by Alin

XML vs. JSONBefore comparing JSON and XML formats, let's start with a brief history lesson about the former data formats (more precisely, the ancestors of XML):

* Generalized Markup Language (GML) was developed in the early 1970 by IBM, and is a set of macros that implemented markup tags for SCRIPT.
* Standard Generalized Markup Language (SGML) was developed based on GML as a markup language used for documents and has become an ISO standard in 1986. Later, in 1998, SGML was reworked into the successful XML.

On the other hand, JSON is a newer data format which was popularized by Douglas Crockford in 2001. The data format started being used mainstream (by Yahoo and Google) in 2005 - 2006.

General facts

Extensible Markup Language (XML) is a markup language that encodes documents in a format that is human and machine readable. One of its goals was the usability over the Internet, and nowadays it is widely used in a variety of applications, web services, web sites etc.

JavaScript Object Notation (JSON) is a lightweight format that transmits data objects as a collection of name / value pairs. It was developed as an alternative to XML and it is now supported by all modern programming languages.

From a syntax point of view, the differences are obvious - please see below the following code snippets:


Code snippet:

	"name": "My Company",
		"streetAddress": "21 2nd Street",
		"city": "Bucharest",
		"country": "RO",
	"phoneNumber": [
			"type": "home",
			"number": "021 555-4567"
			"type": "fax",
			"number": "021 555-7890"


Code snippet:

		<streetAddress>21 2nd Street</streetAddress>
		<phoneNumber type="home">021 555-4567</phoneNumber>
		<phoneNumber type="fax">021 555-7890</phoneNumber>

What are the advantages of each data format?

As you can see in the above examples, thanks to its indentation and white spaces (when properly formatted), JSON is easier to read than XML. Also, because it doesn't use a full markup structure, it is more compact, so it occupies less space (even though this is no longer a major issue nowadays).

Another advantage of JSON is that it can contain more structural information. For example: it is easier to express different data formats such as: numbers (11), strings ("11"), NULL values and even arrays.

On the other hand, XML is still widely used by developers. Being older on the "data format market" brings many advantages, such as: more documentation and more tools to work with it. One more advantage that XML has over JSON is the XML schema. This represents the description of the XML document and is often used for data validation.


In the end, the choice between JSON and XML is subjective. If you are willing to learn about JSON and the libraries associated with it, then you should probably do it because JSON is gaining more and more popularity and usability. On the other hand, if you are a bit more conservative, then you should stick with XML. The markup language proved its worth over the years and it won't be fully replaced in the near future.

So what's your experience with both data formats, and which one do you prefer to use for development?

Tags: Data format 


J commented on 8/8/2014 10:35:02 AM

No mention of XSLT?

Alin commented on 8/11/2014 12:45:42 PM

Thank you for your comment.

Yes, I could have mentioned XSLT, however as this is an XML interpreter and a more complex subject, I thought it would be better to have a blog post of its own.

Click here commented on 10/8/2018 2:18:22 PM

Very popular. It has perfect and precious content material which may be very uncommon in recent times but I'd like to say that this text simply pressured me to accomplish that. In truth quality post!

Gmod free commented on 10/9/2018 8:02:55 AM

I did not perceive that this drawback turned into therefore crucial so standard. You completely placed it in mindset on behalf of me. Years within the past I decided flutter lists immensely usefully, therefore if you relish has been that this is often a way in which additional useful, that’s terribly tempting.I’ll provide this AN attempt.

brands of cbd hemp oil commented on 10/11/2018 12:18:59 PM

In any case, despite what might be expected they lose the idea of its utility or relationship with different protests and capacities with which it is specifically and in a roundabout way related. As you will comprehend these people comprehend and depict the creatures and things going in their thinking from the part to the entirety.

wedding anniversary commented on 10/13/2018 1:01:31 PM

I found this guide most extreme helpful for me thank you a bounty for troublesome work. Propelling a web website rapidly, and your measurements can be extremely advantageous for me. much obliged to you for all your help and wishing all of you the accomplishment of your business.

Visit Us commented on 10/18/2018 9:43:01 AM

There are a few fascinating focuses after some time here yet I don't decide whether these individuals focus to heart. You can discover some legitimacy yet I definitely will grab hold assessment until the point when I investigate it further. Superb article , thanks along these lines we need unquestionably!

Best shoes for sale commented on 10/19/2018 12:27:29 PM

These could be likewise permed, lower, explode dried, alongside outlined similarly as you'll apply your characteristic quality. Wigs consequently created have a more normal appearance and in this manner are smoother when contrasted and their specific fake options. Human hair can be more hearty.


Formal Shoes for men commented on 11/3/2018 10:33:36 AM

This is my testimony about the good work of a man who helped me..My name is Davis ville and I base in USA. My life is back! After 2 years of marriage, my wife left me with our three kids. I felt like my life was about to end, and was falling apart. Thanks to a spell caster called Dr Larry who I met online.


Your Comment:

Blog Home   SBP Home
RSS Feed       Contact


 Blog Archives  |  Terms of Use  |  Privacy Policy
© 2019 SBP Romania. All rights reserved.