Often one of the hardest parts of app development is coming up with the focus of your app. Alternatively, you may have a great idea but lack the data, or you’re looking for that last piece to turn a good app into a must-have download. Well, open data could just be the answer to your problems.
Let’s start with a bit of background on open data. Open data is any data that is published by anyone with no restrictions on access, re-publication, and re-distribution. Typically the only constraints placed on the data is that there be an attribution or share-alike requirement. A great deal of this data is hosted by governments and made available to everyone. Normally the data will be presented in XML or JSON formats, but could also be in Excel files, CSV, Shapefile, and even live or static.
There are a number of benefits to this: someone else is hosting and maintaining the data. As a result, you simply need to access it, process it, and display it. If you pick the right resource, you can even see it updated periodically.
So how to go about picking a good data source? Well, as with anything in your app, it should reinforce your app’s purpose. Have an app that displays restaurant locations? Maybe your users would like help finding a parking place. Or maybe you’re showing supermarkets and wanted to let your users know where to get really fresh fruit.
So you’ve picked a resource and you’re ready to code. You need to plan out your classes and fields to accommodate the open data source and you want to make sure you get it right. Or you could just use Web Essentials for Visual Studios 2012. Why, you ask? There is a very good reason for that: Paste XML as class. It’s also available in JSON flavour.
All you need to do is open your XML or JSON open data source, copy it, and paste it into a .cs file via this option (through the Edit menu, or right-click context menu). Using the JSON from our previous parking example, this is the output.
There you go. Fully formatted; no spelling errors; all your sub-classes and types ready to go. Oh, for any classes that aren’t already defined? It creates those too. Since this is all automatic you don’t need to worry about transcription errors or forgotten fields, and it’s all placed in properties. That means it’s all binding ready. Depending on your coding preferences you can leave it as it is or remove RootObject and name your .cs files accordingly, or add additional fields that you need for other features. It is all just code, after all.
There you go. A full fledged data source without the need to compile and maintain it yourself. I built Sela Canada’s Toronto Events and Festivals and Toronto Open Doors apps using open data, and I can attest that it made the development much faster having access to an existing data source.