Why JSON vs XML is a yawn

Strange spate of discussion recently about XML vs. JSON. On M. David Peterson's Weblog he states what I think is the obvious: there is no serious battle between XML and JSON. They're entirely complementary. Mike Champion responds:

The same quite rational response could be given about the "war" between WS-* and REST, but that has caused quintillions of electrons to change state in vain for the last 5 years or so. The fact remains that some people with a strong attachment to a given technology howl when it is declared to be less than universal. I completely agree that the metaphor of "keep a healthy tool chest and use the right one for the job at hand" is the appropriate response to all these "wars", but such boring pragmatism doesn't get Diggs or Pagerank.

If I may be so bold as to assume that "pragmatism" includes in some aspect of its definition "that which works", I see a bit of a "one of these things is not like the other" game (sing along, Sesame Street kids) in Mike's comparison.

  • XML - works
  • JSON - works
  • REST - works
  • WS-Kaleidoscope - are you kidding me?

Some people claim that the last entry works, but I've never seen any evidence beyond the "it happened to my sister's boyfriend's roomate's cousin" variety. On the other hand, by the time you click through any ten Web sites you probably have hard evidence that the other three work, and in the case of REST you have that evidence by the time you get to your first site.

For my part, I'm a big XML cheerleader, but JSON is great because it gives people a place to go when XML isn't really right. There are many such places, as I've often said ("Should Python and XML Coexist?", "Alternatives to XML", etc.) Folks tried from the beginning to make XML right for data as well as documents, and even though I think the effort made XML more useful than its predecessors, I think it's clear folks never entirely succeeded. XML is much better suited to documents and text than records and data. The effort to make it more suitable for data leads to the unfortunate likes of WXS (good thing there's RELAX NG) and RDF/XML (good thing there's Turtle). Just think about it: XQuery for JSON. Wouldn't it be so much simpler and cleaner than our XQuery for XML? Heck, wouldn't it be pretty much...SQL?

That having been said there is one area where I see some benefit to XQuery. Mixed-mode data/document storage is inevitable given XML's impressive penetration. XQuery could be a thin layer for extracting data feeds from these mixed-mode stores, which can then be processed using JSON. If the XQuery layer could be kept thin enough, and I think a good architect can ensure this, the result could be a very neat integration. If I had ab initio control over such a system my preference would be schema annotations and super-simple RDF for data/document integration. After all, that's a space I've been working in for years now, and it is what I expect to focus on at Kadomo. But I don't expect to always be so lucky. Then again, DITA is close enough to that vision that I can be hopeful people are starting to get it, just as I'm grateful that the development of GRDDL means that people in the Semantic Web community are also starting to get it.

On the running code front I've been working on practical ways of working nicely with XML and JSON in tandem. The topic has pervaded several aspects of my professional work all at once in the past few months, and I expect to have a lot of code examples and tools to discuss here on Copia soon.

[Uche Ogbuji]

via Copia
3 responses
On the pragmatism of WS-*, see Eric Newcomer's post http://blogs.iona.com/newcomer/archives/000431.html I linked to; the gist of it is that WS-* is being widely criticized these days because it is so widely used that its warts are obvious, but warts and all it is solving more problems than it creates. Obviously it is not being widely used in the ways that its advocates envisioned in 2001 or so, since it is really about "enterprise services" than "web services"... but then neither is XML primarily used as envisioned as "SGML for the Web".  For that matter, HTTP is widely used in all sorts of ways that violate Fielding's vision and the spec itself (e.g., GET with side effects), but that's because we live in a world govererned by evolution rather than intelligent design.



But the more interesting point you raise is "XQuery for JSON. Wouldn't it be so much simpler and cleaner than our XQuery for XML? Heck, wouldn't it be pretty much...SQL?".  I know that lots of people, especially Tim Bray, strongly disagree, but if you think of something like the XQuery data model rather than the XML syntax as the unifying principle, XQuery over JSON makes perfect sense (to the extent that there is a canonical mapping from the XQuery data model to JSON). SQL doesn't do the job because it is so clumsy to use with hierarchal data models of the sort that are easily represented in XML or JSON. 



Let's hope that "JQuery" and "JSLT" and "JSDL" don't pop up to muddy the waters further.
"The topic has pervaded several aspects of my professional work all at once in the past few months, and I expect to have a lot of code examples and tools to discuss here on Copia soon."



NICE!  Looking forward to them!
So Mike, you link to someone who links to an article that claims, without a further link,  based on a survey, that "Forty Percent of All SOA Projects Are Finished in Three Months".  This thrice-removed article is barely more than a scattered and incoherent jumble of odd quotes and other strange conclusions drawn from said survey.  Speaking of surveys, John Cowan just yesterday linked:

http://www.megginson.com/blogs/quoderat/2006/12/22/its-ok-to-wish-me-merry-christmas/#comment-19002


to this beaut:


http://itre.cis.upenn.edu/~myl/languagelog/archives/003954.html


Enough said about how rickety surveys can be as a source of evidence.  And never mind the fact that the survey focused on "SOA", which no one can even define, and can't reliably be identified with WS-Kaleidoscope--most definitions of SOA are vagaries along the lines of "the data is the interface", which could apply as much to REST as to WS-Foo.



What did I say about "it happened to my sister's boyfriend's roomate's cousin"?  Thanks for helping me REST my case (OK I'll blame the bad pun on the sip of 100 proof Root Beer liquor I just had at a Christmas get-together :-) ).