What is the practical difference between xml, json, rss and atom when interacting with Twitter?

I am new to web services and as an introduction I am playing with the Twitter API using the Twisted framework in python. I read about the various formats that they offer, but it is still not clear to me which one I should use in my rather simple project. In particular, the practical difference between using JSON or XML is what I would like to consult. All I do is request a public timeline and cache it locally.

Thank.

+5
json python xml twisted twitter
Jan 17 '09 at 11:19
source share
3 answers

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/

+7
Jan 17 '09 at 14:45
source share
β€” -

RSS and Atom are XML formats.

JSON is a string that can be evaluated as Javascript code.

+4
Jan 17 '09 at 11:21
source share

I would say that the amount of data sent over the wire is one of the factors. The XML data stream will be larger than the JSON for the same data. But you can use everything you know more / have more experience. I would recommend JSON as it was more "pythonic" than XML.

+1
Jan 17 '09 at 11:24
source share



All Articles