Using JSON as a blog RSS feed

JSON is gaining its momentum. Many websites have started using this format as their default format of choice for data exchange. One of the main reasons behind this choice is that JSON is a simple and lightweight format. RSS, on the other hand, is basically XML, implying that this format is more suitable when you have to deal with complex data structures, since XML is particularly useful for adding semantics to describe data (think about RDF, for example).

An RSS feed, in its basic structure, is actually simpler than most developers think. For example, take a look at the following excerpt taken from a sample RSS feed:

<?xml version="1.0"?>
<rss version="2.0">
      <title>Liftoff News</title>
      <description>Liftoff to Space Exploration.</description>
      <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
      <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
      <generator>Weblog Editor 2.0</generator>
         <title>Star City</title>
         <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href="">Star City</a>.</description>
         <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
      <!--more item elements here-->

As you can see, this is not a too complex structure. Using JSON, you can rewrite the above feed like so:

{"rss": {

    "channel": {
        "title": "Liftoff News",
        "link": "",
        "description": "Liftoff to Space Exploration",
        "language": "en-us",
        "pubdate": "Tue, 10 Jun 2003 04:00:00 GMT",
        "lastbuilddate": "Tue, 10 Jun 2003 09:41:01 GMT",
        "docs": "",
        "generator": "Weblog Editor 2.0",
        "managingEditor": "",
        "webmaster": "",
        "item": [
             "title": "Star City",
             "link": "",
             "description": "...",
             "pubdate": "Tue, 03 Jun 2003 09:39:21 GMT",
             "guid": ""
            // more items here


This is only a showcase to demonstrate that some peculiarities of the JSON format are really interesting from a development point of view. Most of all, a JSON feed is noticeably faster to parse than a normal XML/RSS feed and requires less resources. Further, all server-side languages include some methods or functions to encode and decode JSON data. Finally, it's worth to be mentioned that now the vast majority of web browsers are able to parse JSON natively.

Leave a Reply

Note: Only a member of this blog may post a comment.