this is aaronland

“I was just lying here thinking...'bacon'”

There is nothing more permanent than a temporary hack

I still don't like JSON. It works and working code always win but its arrival as the next Best Thing Evar on the Intarweb only confirms that it's a hack. I don't have any problem with lightweight and simple data structures but I just can't get excited about them as an exchange mechanism between disparate services.

I have spent more time than is healthy writing wrapper code for too many web services to buy into, really, any kind of XML to hash of lists of hash of hashes magic. I'm a Perl hacker so that kind of nonsense come naturally but it's just a waste of time when there are tools like XPath.

Coincidentally, I tend to think of XPath the same way its benefactors think of Perl : It makes easy things easy and hard things possible. XPath can be very complex if you are dealing with a complicated document (or fantastically stupid formats like Apple's plist) but 90% of the time it's really nothing more than specifying a simple set of parent-child relationships.

Insert pithy comments about foreach-ing over all those nested arrays (or were they hashes?) in JSON here.

The W3C recently announced its Scrumjax (web APIs) Working Group which, despite some seriously pendantic blathering on the mailing list, is a good thing all around. But if I were in their shoes, I would tack on a brief tangent before getting back to the hard work : Stop all the hand-wringing about the bloody Back button long enough to spec out the requirements to do safe cross-domain XMLHttpRequest calls.

Once that's been blessed we can beg and plead with the browser hackers to implement it and then we can get back to using all the goodness that comes with the support for XPath and XSLT and XForms and E4X that is finally starting to percolate out of the dev branches. There is genuine desire to play nicely across domains and people will use JSON for the simple reason that : It works.

You may recall that I've spent a lot of time clawing at the cross-domain security wall. You may also recall that I like to mix and match metadata elements from various sources. I really like to do this inline because I am lazy and easily irritated by having to drag browser windows around. And did I tell you that I don't like running proxy services because they just as much a time-sink as they are a pain in the ass and are generally bad for privacy all around?

We get asked, periodically, to return results for the Flickr API in JSON. No one on the team thinks it's a bad idea but the reasons why it hasn't happened yet are, when they're not any of your business in the first place, pretty boring.

But what about syndication feeds? Way back when I wrote a JavaScript/bookmarklet hack that would look for <meta> tags similar to those used by the New York Times, taggify their contents and display photos from the corresponding Flickr tag feeds. What if you could do that with JSON instead of XML?

Well, here's is a handy bookmarklet for doing just that : What does Flickr think about this page?

The bookmarklet is hard-coded to look for New York Times style meta tags but the underlying code is written such that you can plug in your own keys. For example :

   # The tags used in this page :

   <meta  name="des" content="json; javascript" />
   <meta  name="per" content="aaron" />
   <meta  name="org" content="flickr" />
   <meta  name="geo" content="sanfrancisco" />

   var flickr = new FlickrTags ();

   # Or, you could roll your own :

   <meta  name="delicious" content="montreal; resto; review">

   var flickr = new FlickrTags ();

Code-wise, it is made up of four separate libraries/scripts to spawn a floating window with icons that you can drag around the browser window. Clicking on an icon will display a larger version, using Lightbox-fu, that links back to the photo's Flickr page. Each of the dependencies has been tweaked slightly either for the sake of functionality or just to account for the allowable randomness in the syntax of the language. They are :

A pre-bookmarklet-ized version is also available for the curious. It is held together with duct tape at the moment and will not work in every browser. Yet. I have tested it on Firefox 1.5 and it all works swimmingly. I know for a fact that it won't work in Safari. Patches are welcome.

Things I like about San Francisco

Going to Ocean Beach and watching the 747s, taking off from SFO, rise and bank over the water.