Psychologists say that shame is the most powerful human emotion. Well, I wouldn't be too quick to write off spite. During last month's del.icio.us upgrade, a valuable means of tapping into the hivemind of taggers was inexplicably turned off. I vowed revenge and today has seen the generic JSON feed return, with all the elegance, robustness and civic-mindedness of a dodgy third world electricity hookup.

First, the backstory. Perhaps the most important part of "social bookmarking" is the "social" bit. This means you can access the whole community's bookmarks, for example:

Note that no particular account is specified - here I'm asking for all pages tagged "blogger" by anyone. (Hence the term "generic".) Delicious, in their wisdom, allowed users to get at this information by publishing it as a JSON feed.

This feed format is a super-lightweight replacement for XML, like RSS without the trimmings. It's also what FreshTags uses to support in-blog navigation. This opened up a raft of novel and experimental uses of tag-driven content to enhance boring static pages. Freed from the restrictions of nominating a target delicious account or a pre-ordained set of tags, users could serve up a sidebar full of fresh links based on inbound search queries or free-form text entry by readers. We were just getting started and more exciting and disruptive possibilities were open.

Step One. Locate a RSS2JSON conversion service. This is where I offer a thousand thanks to the pioneering work of John Resig - who, I might add, has a very powerful Javascript framework in jQuery. He offers a conversion service that (unsurprisingly) takes an RSS feed and converts it into its JSON equivalent. It looks like this:

http://ejohn.org/apps/rss2json/?url=URL&callback=CALLBACK

Where URL is the required RSS feed (in my case, http://del.icio.us/rss/tag/*) and CALLBACK is the name of your Javascript callback function.

Step Two. Write a suitable callback function. What's this? Well, it's a function that gets wrapped around your JSON object before being sent back to your page by ejohn's app. I called mine delify() since its job is to take the ejohn-style JSON object and convert it into the delicious-style JSON object. This just involved mangling things around and renaming. For example, "link" becomes "u", "title" becomes "d" etc.

Now that the resulting JSON object is indistinguishable from what delicious used to return, FreshTags can quite happily tear it apart, put it back together and render it nicely on your page. Check it out:

Or, to try tag-grabbing, select a tag from the left on this blog and then visit my homepage.

Astute readers will notice that you can enter whatever text you like in the field and FreshTags will process it (via delicious and ejohn) asynchronously. That's right, no more reloading the page each time you change tags! This is a sneak preview of what's coming up in the next release. NB: I probably haven't done it quite right, so advice from seasoned AJAXians would be appreciated (privately please; no need to publicly run me down :-)

Sadly, I have to point out that I won't be incorporating ejohn's hosted rss2json hack into the next release of FreshTags, owing to the unfair burden on his servers and link. So this one-off implementation remains on my homepage as a form of silent protest, as well as a proof-of-concept. If you'd like to see this generic mode return to FreshTags, please lobby delicious to turn feeds/json/tag/* back on, or persuade your favourite bookmarker to go JSON, or even offer to host ejohn's rss2json yourself!

That said, it is reassuring to know that such a service is in principle available (John Ressig's code is released under a Creative Commons licence). This is especially important given the rise of a range of socialbookmarkingservices offering RSS feeds - but not JSON.

Perhaps this finally frees FreshTag users from the hegemony of delicious ...

Update: John "ejohn" Resig wrote to inform us that his service sometimes gets temporarily banned by delicious, for making too many hits. Also, it doesn't seem to handle tag intersections too well. So best use one tag at a time and if it's down, try again the next day.

Yes, that's right. FreshTags will be going asynch, plus with blogrolling. Release date is hopefully this month, though my PhD has a way of rudely imposing itself in my life from time to time. (Less than 60K words to go now. Yeah!)