For me it comes down to convenience. Using XML, I have to parse the response in the DOM (or, more often, ElementTree). Using JSON, one call to simplejson.loads (json_string), and I have my own Python data structure (lists, dictionaries, strings, etc.), which I can start to iterate and process. In my opinion, everything that means writing a few smaller lines of code is usually a good idea.
I often use JSON to move data structures between PHP, Python, and JavaScript - again, because it eliminates the need for me to serialize XML and then parse it at the other end.
And, as jinzo said, JSON ends with a bit less bytes on the wire.
You can find my JSON blog post a couple of years ago useful: http://simonwillison.net/2006/Dec/20/json/
Simon Willison Jan 17 '09 at 14:45 2009-01-17 14:45
source share