Navarr's Tech Side The Technical Side of my Life

26Nov/090

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.

Tagged as: , , , No Comments
23Sep/090

Needed: An Open-Protocol System for Commenting on the Web

One thing that many blogs have embraced is the trackback system for blogs to shout out to other blogs that they’re linking to them or using their information.  This is a wonderful idea, and a similar solution should be applied to comments.

Now, I’m not fully up to speed with micro-formats and RDF, and such, but such a system should be easy to create and implement.  The first thing we should do is extend RSS to include it.  We already have the <comments> tag, which should obviously link to an RSS feed of comments for the item (using this new system, anyway.)  So we need to add a <postComment> tag, yes?

This tag could go in either the <channel> element (for Comment-Streams) or in the <item> element (for news-streams and/or as a direct reply to other comments).  Lets break it down something like this:

   1: <postComment method="post">

   2:     <link>http://www.example.org/postComment.php</link>

   3:     <input type="hidden" name="newsID" value="12345" />

   4:     <input type="text" name="name" required="true" />

   5:     <input type="text" name="email" required="true" />

   6:     <textarea name="comment" />

   7:     <captcha>

   8:         <link>http://www.example.org/captcha/render.php</link>

   9:         <desc>How many kittens are in the picture?</desc>

  10:     </captcha>

  11: </postComment>

This would allow a large amount of customization for systems that have different fields without too much change needed.  Just an extension to the current RSS spec.  Essentially something similar could be done.  What are your thoughts, improvements, and ideas for this?

6May/080

The Day the Internet Broke

Everything was going normal, until I wanted to go look at my feeds using the wonderful Google Reader of course, when this showed up in my browser:

Then, I asked twitter about it and got a reply from who is now a newfound friend @MathGeek06, who reported that he too was having troubles.  After a couple messages or so, I got this:

It looks like the Internets are conspiring against me tonight.  Google, tell me, why are you crashing so much lately?  We need you, we depend on you, YOU ARE THE INTERNET!

I'm just kidding of course, but this has allowed me ample time to reflect on how dependent I am on central services.  Just about the same time as I was giggling at Dave Winer for blogging about Why Decentralizing Twitter is so important. I'm starting to agree with him.