Tuesday, July 21, 2009

JSON, in retrospect

In May of 2006, I sent this message to a friend. It's funny that the "see for yourself" page is no longer titled "see for yourself", probably because people actually did "see for themselves" and perhaps reached a conclusion similar to the one I reached below. In hindsight, JSON is wonderful and I still consider it to have different use cases than XML. I continue to heavily use both JSON and XML in my day-to-day tasks.

From: Geoff Hendrey
Sent: Wednesday, May 24, 2006 10:31 AM
To: Brent Hamby
Subject: Json questions

Hey dude,

I went to the json "see for yourself" page: http://www.json.org/example.html to compare the Json equivalent of XML.

I copied each of the examples into notepad and wrote down the size-on disk:

json size (bytes) XML size (bytes) (json size)/(XML size)
604 630 95%
252 221 114%
630 656 96%
3554 10708 33%
898 1150 78%

AVG (json size)/(XML size)

Based on an average size compaction to 83.2% of the XML size. Also, if you look at the 4th example they give (line 4 of the table above), they did a Json version of web.xml. Now web.xml is a notoriously bad XML design. It basically doesn't use ANY attributes, so you get pretty nasty tag bloat. So if we drop the 4th comparison, as being kinda silly, we get an average compaction to 95.4% of the original size. Is saving 4.5% really a big advantage?

I also saw several statements on the json web page that I would put in the "wacky" bin. This may just be personal preference, but I found the XML documents much easier to read than their json equivalents. The Json looks, to me, like "code", kinda like a snippet of PERL or something.

Anyway, it seems clear that being able to easily marshal an object representation of your data makes it much easier to develop software in any programming language. But it seems to me that json is munging this idea up with the wire format, which to me are orthogonal concerns.

No comments:

Post a Comment