XML to JSONML Client-side Proxy

When integrating with other web services, there are often shortcomings in third-party API’s. One of the most common ones I’ve had to deal with is the lack of JSON+callback support. To circumvent this problem, I wrote a tool that can use an API’s XML calls to do the same trick.

JSON+callback allows you to do loose integrations in Javascript, requiring no development on the server-side of things. This is really useful if you for example, quickly want to fetch Lastfm’s track information and render a player, like on this Kakuteru page. Lastfm didn’t support JSON+callback support in their API until recently. After a lot of whining by developers, they finally dadded support.

Still, services like Imeem, don’t support the JSON callback yet. So for those service, you can use this tool. Basically, it is a Adobe Flash based converter (written in ActionsScript 3) that converts the XML to a JSONML compatible Javascript Object (JSON).

All you have to do is put a swf_to_json.swf and a swf_to_json.js file in your codebase, and use simple Javascript syntax to do remote calls:

    <script type="text/javascript" src="xml_json_proxy.js"></script>
    <script type="text/javascript">
      function callback_on_error(code, message) {
        alert(code + ': '+ message);
      function callback_on_success(url, jsonml) {
      proxy = new XMLJSONProxy('error_callback');

Performing a GET call (POST support is yet to come):

    proxy.get('callback_on_success', 'http://url.of.call.xml/');

Check the XML to JSON Github repository for more documentation, example code and the source code.

Note: While developing this my stupid Flash IDE didn’t tell me that the crossdomain.xml was set to deny on video.google.com, so make sure that the crossdomain policy on the API side is set to open.

This entry was posted in Uncategorized. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • About this Blog

    Hi, I'm Dominiek. I'm the CTO & Co-founder of Bottlenose.com. This blog is about Technology, Innovation and the Web.