Tim Bray on JSON and XML

Don Box's Spoutlet

Syndication

Tim has an interesting post comparing JSON and XML that has me wondering about several things.

Here are some specific questions I have with the piece:

1. I don't see any reason why JSON has different streaming characteristics than XML. Every JSON parser I've written has a streaming I/O layer at the bottom and defers buffering (and type mapping) to a layer above, just like most modern XML stacks.  Why is XML inherently more streamable?

2. Like Joe Gregorio states in the comments on Tim's post, I also prefer JSON's simplification of only allowing UTF-*-based encoding.

3. Tim states that you should use XML when the order of data matters, but JSON has a perfectly reasonable ordered compositor (arrays) that gets used a heck of a lot.

4. I'm also not buying the JSON isn't extensible argument. There's nothing stopping the consumer of a JSON value from ignoring fields whose labels don't make sense. Yes, this requires using convention to avoid namespace collision, but I'm not convinced this is such a bad thing after living for almost a decade with XML namespaces.

5. As for text handling, the things I love about JSON (vs. XML) are you can trivially distinguish numbers from text-that-looks-like-a-number and more importantly, you can represent strings that contain control characters without resorting to base64 encoding. I also don't miss the ambiguity of significant vs. insignificant whitespace.  With JSON, it's obvious from the data. With XML, you need a DTD or schema to know for sure. Tim's defintely Mr. Text so I'm sure he'll tell me that I'm wrong to want these features :-)

6. As for renderability, I fail to see how this: { “FirstName”: “Tim”, “LastName”: “Ewald” } is inherently any less renderable than the XML equivalent (I'd type it in here but for the life of me I can't get .TEXT to escape things correctly). Yes, I can apply an XSLT to the latter to produce HTML, but what if I'm a Swing or AWT or User32 or Avalon user?

In short, I think the biggest advantage to XML over JSON is inertia. XML is here, there are tons of tools, and there is a ton of data.

JSON has a huge hill to climb to displace XML for new applications that don't already have a Javascript/Browser component (thanks Dare). 

That stated, it has simplicity and fashion trends on its side.

 


Posted Jan 03 2007, 08:25 AM by don-box

Comments

Dare Obasanjo wrote re: Tim Bray on JSON and XML
on 01-03-2007 10:23 AM
I disagreed with Tim's piece as well but for different reasons. It completely missed the point of why JSON is popular on the Web and why XML is unlikely to regain popularity in the places that JSON is taking over.

>JSON has a huge hill to climb to displace XML for new applications.

Poppy cock.

PS: You should read my blog more.
Stefan Tilkov's Random Stuff wrote Tim Bray on JSON and XML
on 01-03-2007 1:33 PM
Don Box wonders about several things addressed in Tim Bray’s XML vs. JSON post. Don surely hasn’t been working on Indigo/WCF for quite some time — I wonder what his current job is? :-)...
Dare Obasanjo aka Carnage4Life wrote XML Has Too Many Architecture Astronauts
on 01-03-2007 5:30 PM
Rahul wrote re: Tim Bray on JSON and XML
on 01-04-2007 12:17 AM
> ...any less renderable than TimEwald.

You need to escape your angle brackets there. I can see the unescaped XML tags in your source.
Matthias Hertel wrote re: Tim Bray on JSON and XML
on 01-04-2007 9:35 AM
JSON also came because we had no solid SOAP client in the browser. But it's never too late... (and you can get one from my site)

In 1999 it was easy to use XML and SOAP just because SOAP was simple then. JSON is still simple and that's the advantage of the moment.

When building business applications we need more WS-features and things become more complicate - and you know.
Should we have a "JSON-Standard" including schema, security, addressing...?
I cannot make decisions but I prefer that Firefox finishes their buggy SOAP client implementation and Microsoft delivering the existing SOAP ActiveX control with the IE.
subbu.org wrote JSON as a General Purpose Alternative?
on 01-04-2007 11:41 AM
The discussion at Dare Obasanjo's blog, and the references to some other recent posts motivate me to look at some of the broader arguments being made. It is clear that processing JSON data using JavaScript is trivial, and that is what makes JSON a popular alternative over XML currently. All other advantages and disadvantages over XML are incidental. If we take out JavaScript from the picture, JSON is not a clear winner. Both JSON and XML take some effort to parse and process outside JavaScript....
lb wrote re: Tim Bray on JSON and XML
on 01-04-2007 7:39 PM
>You need to escape your angle brackets there.
>I can see the unescaped XML tags in your
>source.

somehow it's reassuring to know that even don box forgets to escape his angle brackets

;-)
Amusing wrote re: Tim Bray on JSON and XML
on 01-14-2007 9:06 AM
If this isn't a point in favor of JSON and against XML, I don't know what is:


"6. As for renderability, I fail to see how this: { “FirstName”: “Tim”, “LastName”: “Ewald” } is inherently any less renderable than the XML equivalent (I'd type it in here but for the life of me I can't get .TEXT to escape things correctly). Yes, I can apply an XSLT to the latter to produce HTML, but what if I'm a Swing or AWT or User32 or Avalon user?"
dbox wrote 就Tim Bray对JSON和XML的比较的几点看法
on 01-24-2007 1:16 AM
Tim????????,???????JSON?XML?????????????????????
audio, video, disco wrote JSON vs. XML
on 01-24-2007 7:50 PM
Lately, several smart people have been weighing in on this debate. In partial web page refresh (AJAXian)
Sendhil Chokkalingam wrote re: Tim Bray on JSON and XML
on 04-01-2007 10:40 AM
Although XML is matured and has lot of tools to support it but I think JSON will grow. Compared to XML I see that JSON has huge performance benefits
-reduced cpu parsing time compared to XML
-reduction in bandwidth usage
-smaller payload compared to XML hence applications will have natural performance boost

Does anyone disagree
Is JSON the Developers Choice? wrote Is JSON the Developers Choice?
on 08-11-2010 6:39 AM

Pingback from  Is JSON the Developers Choice?

Add a Comment

(required)  
(optional)
(required)  
Remember Me?