Home > Uncategorized > A better XML to JSON proxy

A better XML to JSON proxy

I was looking for a generic way to convert XML to JSON, and I came across this GAE version http://jsonproxy.appspot.com/proxy, however, I noted that it only converted the first node of any tree to JSON, so it missed out most of the data contained in the XML.

Lets say,  we wanted to load exchange rates into a mobile app running Javascript (read phonegap /Wrtkit /Webos), an XML feed can be found at http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml (European central bank), but it’s easier to work with JSON than XML in Javascript. If you use the GAE (google app engine) version, then you only get USD, so I wanted to write my own proxy to fix this.

So, with the help of a free .NET Hosting account from brinkster Which worked an absolute charm – I didn’t have to put load on my own server to run this!. I installed my own XML-To-JSON Proxy:

I’ve fixed this, in a C# Implementation:

http://<url>/default.aspx?url=http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

vs

http://jsonproxy.appspot.com/proxy?url=http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

(obviously, you need to urlencode any querystring parameters after the URL in both cases)

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: