Why I now Prefer JSON to RSS/XML
This might mainly be a “call-out” to Dave Winer, since he is continually attempting to push RSS for all sorts of data that should be inherited around the web – although, he has stated before that he likes JSON – I think – My memory is not so good, even my girlfriend has been complaining about it.
Either way, I’m just going to take a small amount of time here to list why I no longer like XML and RSS for portable data.
It’s too low-level.
XML and RSS are a markup language, of course. It’s very low-level code, and is generally a pain to parse in any language. Which is why I prefer JSON.
It’s high-level code.
JSON is a very simple object – It’s basically an array of data. Here is some XML vs. JSON:
XML
<data>
<user id="876232">
<name>User Name</name>
<screenName>User</screenName>
</user>
</data>
JSON
"user":["id":876232,"name":"User Name","screenName":"User"]
Even though you can get similar results by making id its own tag in the XML, its still difficult to parse. Where as with JSON, the data is already formatted and easily accessible. Especially in my favorite language, PHP.
// For Json
$json = json_decode($data,TRUE); // Decodes JSON and makes it a true array
$id = $json["user"]["id"];
$name = $json["user"]["name"];
// For XML
$xml = new SimpleXML($data);
$id = $xml->user["id"];
$name = $xml->user->name;
The two are very close, but in the end JSON is more simplistic – because its such a high-level language.