tags:

views:

878

answers:

3

When I first saw XML, I thought it was basically a representation of trees. Then I thought: the important thing isn't that it's a particularly good representation of trees, but that it is one that everyone agrees on. Just like ASCII. And once established, it's hard to displace due to network effects. The new alternative would have to be much better (maybe 10 times better) to displace it. Of course, ASCII has been (mostly) replaced by Unicode, for internationalization.

According to google trends, XML has a x43 lead, but is declining - while JSON grows.

[edited] Will JSON replace XML as a data format?

  1. for which tasks?
  2. for which programmers/industries?

NOTES: S-expressions (from lisp) are another representation of trees, but which has not gained mainstream adoption. There are many, many other proposals, such as YAML and Protocol Buffers (for binary formats).

I can see JSON dominating the space of communicating with client-side AJAX (AJAJ?), and this possibly could back-spread into other systems transitively.

XML, being based on SGML, is better than JSON as a document format. I'm interested in XML as a data format.

XML has an established ecosystem that JSON lacks, especially ways of defining formats (XML Schema) and transforming them (XSLT). XML also has many other standards, esp for web services - but their weight and complexity can arguably count against XML, and make people want a fresh start (similar to "web services" beginning as a fresh start over CORBA).

[edited Mar2010] Like NoSQL, JSON is schemaless.

+3  A: 

I think JSON has already largely replaced XML for client-side communications with a web server, but that will likely be the extent of its dominance. As you stated, XML provides advantages that are appropriate for server-to-server interactions.

Jess
JSON has already largely replaced XML? Sure?XSLT works with JSON? DOM works with JSON? Java and .NET XML APIs work all with JSON as good as with XML? Did I miss something? ;)
ivan_ivanovich_ivanoff
Yes, JSON is rapidly replacing XML for RPC-style communication: not just AJAX from browser, but server to server. Major web 2.0 companies are doing it, and I was personally very surprised to see how fast it has happened at company I just joined.XSLT is not used (for good reason) for data-oriented use cases; DOM likewise. Data is best consumed as bound objects.Put another way: SOAP-style communication has become a legacy thing, becomes "Corba of 2000s". XML still has its place for markup (Docbook, office etc) of course.
StaxMan
+4  A: 

Replace XML? Which XML?

There is "XML - the kind of data structuring" and "XML - the the textual representation of this structuring".

So, while the textual representation of XML can be replaced by many means (JSON, YAML, ...), it would not replace the structural properties (there's a tree, elements with attributes, sub-elements and text nodes).

There are formats which store and/or process XML-structured data while neglecting the textual form. Examples:

  1. DOM - stores an object tree in memory in an transformation-efficient form.
  2. EXI - future format to store/transmit XML data in binary-optimized form.

So, textual representation of XML can be "replaced" by transforming the standard XML notation to something else and back again. (XML to JSON, and back to XML)

But, the structural properties and all technologies based on them, can not be "replaced", because this would just break all standards. So no one is doing this. There are just alternative textual representations being read to in-memory DOM or other formats, achieving a higher level of abstraction thus neglecting the underlying textual form.

ivan_ivanovich_ivanoff
+5  A: 

Short answer: yes and no (EDITED as per comments below)

There are fundamental differences and trade-offs. XML is a markup language, particularly suitable for textual documents (xhtml, docbook, various kinds of office docs). And good enough for many other tasks. Problems mostly arise for it having hierarchic model (instead of, relational as in SQL, or object-graph as in oo languages).

JSON is an object notation, meaning it has bit more natural fit for handling data-oriented use cases; cases where xml sort of works, but where there is more cost in overcoming impedance between object and hierarchic models. JSON is not a perfect fit -- it's still data, not objects (no identity, can't do full graphs) -- but it is more natural than XML. And as such, it is easier to build tools to do good decent and simple data binding.

So: there's plenty room for both, and I would expect both to be used for long time to come. Not always in optimal way, but both can do plenty of use cases well enough.

For what it is worth, since writing my original answer, I have seen JSON absolutely annihilate XML for data-oriented/data-interchange use cases for companies I have worked for. SOAP (etc) will start significantly shrinking, and "plain old JSON" data interchange (esp. with RESTish frameworks, JAX-RS for Java for example) will take over.

And yet XML is much better for textual markup.

StaxMan
Thanks for your answer. Please see buried in the question I say "I'm interested in XML as a data format." I really mean to be asking will JSON replace XML as a data format? You seem to be saying "yes". (title edited)
13ren
Sorry I missed that. Yes, I do think JSON is bit better, and over time will handle more of those use cases than XML.I don't think it will replace XML, for variety of reasons however. But I think it will become more important.
StaxMan