JSON vs. XML

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Verahta
Posts: 440
Joined: Wed Aug 24, 2011 1:50 am

JSON vs. XML

Post by Verahta »

This came up in another thread and I thought it might deserve it's own thread. What are your own opinions on JSON vs XML? He is probably biased, but the 'creator' of JSON explains in this short interview why it's better than XML (at least in his opinion, though he does give tangible reasons).

Discovering JavaScript Object Notation with Douglas Crockford
https://www.youtube.com/watch?v=kc8BAR7SHJI
Last edited by Verahta on Tue Aug 05, 2014 10:43 pm, edited 1 time in total.
"In order to understand recursion, one must first understand recursion".
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: JSON vs. XML

Post by Jackolantern »

JSON is, for the most part, a better choice. It is more readable and compact. Plus, with the increasing popularity and ubiquity of Javascript, the fact that JS can natively consume JSON data without any library or translation required is quite handy.

For any online game, the compactness of JSON data can end up being a huge bandwidth saving when you look at a whole month at a time.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: JSON vs. XML

Post by Chris »

JSON is very simpe and straight foreward, you cannot define relations to parts of data. XML can be used for small scale (preferably not) to very large complex relational structures.

It's like comparing procedural code with asynchronous. Or comparing classical mechanics with Quantum mechanics.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: JSON vs. XML

Post by Jackolantern »

JSON can represent relations. To my knowledge, XML cannot represent anything that JSON cannot also represent. They are both just different ways of representing data's structure.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: JSON vs. XML

Post by Chris »

Jackolantern wrote:JSON can represent relations. To my knowledge, XML cannot represent anything that JSON cannot also represent. They are both just different ways of representing data's structure.
the whole benefit of XML is not only being able to place data withing the tag, but also adding parameters:

Code: Select all

<entity parameter="property value"><secondaryEntity /></entity>
To achieve this with JSON would be rather difficult as you only store lists of data or singularity data.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
kaos78414
Posts: 507
Joined: Thu Jul 22, 2010 5:36 am

Re: JSON vs. XML

Post by kaos78414 »

Chris wrote:
Jackolantern wrote:JSON can represent relations. To my knowledge, XML cannot represent anything that JSON cannot also represent. They are both just different ways of representing data's structure.
the whole benefit of XML is not only being able to place data withing the tag, but also adding parameters:

Code: Select all

<entity parameter="property value"><secondaryEntity /></entity>
To achieve this with JSON would be rather difficult as you only store lists of data or singularity data.
Why wouldn't this suffice?

Code: Select all

{ "entity": { "parameter":"property value", "secondaryEntity": { } } }
w00t
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: JSON vs. XML

Post by Chris »

That could be processed to the same result but it took three objects instead of two. The way I look at it is in two directions. XML can go both, JSON can only go in one.

Like RNA and DNA.

Try developing a Windows 8 App with XAML, you'll come to terms with it.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Verahta
Posts: 440
Joined: Wed Aug 24, 2011 1:50 am

Re: JSON vs. XML

Post by Verahta »

"In order to understand recursion, one must first understand recursion".
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: JSON vs. XML

Post by Jackolantern »

XML is a better fit to me for UI-related work, such as XAML or Android UI. So I will definitely give XML that. Comparable UI systems made with JSON (and there are only a couple I know of) just feel clunky and foreign. I don't know if this actually has anything to do with its abilities, or just that XML feels like HTML.

However, I much prefer JSON for actual data transfer.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: JSON vs. XML

Post by Chris »

"XML is like violence. If it doesn't solve your problem, you're not using enough of it."
- Unknown | Chris Maden
I lol'd
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “Coding”