Atom on JSON

Atom is a widely used XML format for syndicating content. But what if you want to use JSON? You can use Google Data Protocol, but the format carries a lot of XML baggage with it. It doesn’t really play to the strengths of JSON. IMO, JSON’s strengths are:

  • Simplicity. No namespaces. (The flip side of this is that JSON isn’t as extensible as XML).
  • Lightweight (in terms of file sizes)
  • Readability
  • Easy to navigate the object graph in javascript

One excellent use case for JSON is syndicating content for mobile HTML+JS apps (using PhoneGap, for example).

Here are some JS-friendly Atom examples (and their XML equivalents). A few things to note:

  • In addition to Atom, the structure borrows from MRSS and OpenSearch
  • Atom allows for several content types. To keep the structure simple, i’ve assumed a type of “xhtml”. This makes sense for HTML+JS apps.
  • Because this is JSON, XHTML content can be a fragment (without a parent node). This avoids additional nesting of data.
  • Atom supports many types of link but there are two which play a pivotal role – i think the 80/20 rule applies. They are promoted to first class citizens.
    • rel=”self” is crucial for providing detailed data for each feed entry. In our case, “application/json” makes sense.
    • rel=”alternate” is useful for providing an RSS style link to an HTML page. In our case, “text/html” makes sense.

I think this would have value as a JSON microformat/schema (AtomJS?).

It would increase portability of feeds, apps, tools and services. It would mean less documentation of proprietary feeds. It could act as an “anchor” for feed formats (changing formats is painful for servers and clients). In short, it can make everyone’s life easier.

The format is as extensible as any other (non-namespaced) JSON format.

What do you think? Add a comment below.

UPDATE: Metro UK are now using the format – try it!

UPDATE #2: Related discussion here –


Leave a Reply

%d bloggers like this: