Web Essentials for Visual Studio: Open Data Made Simple

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.

A Bit of Background

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 do 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.

Get Ready to Code

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, to make life simple, you could just use Web Essentials for Visual Studio. 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

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.

So you’re wondering how you find these magical data sources?  Well, you can check the Canadian government website or the United States government Data.gov site.

Comments (5)
  1. Sean says:

    Very nice post Mark. It looks like a true pro

  2. markm@selacanada.ca says:

    Thanks, Sean. Open data is pretty exciting right now. There's a lot of municipalities following the Federal and Provincial governments' leads and we're seeing tons of new resources added.

    And I'm really loving Web Essentials. I installed it for another reason (can't remember what, actually) but when I found the Paste as Class feature I fell in love. It's a really great resource and kind of should be integrated into VS. I mean, it is essential after all. (Couldn't resist.)

  3. Hello mark says:

    Thank you for the post.

    Do you know if can I use that feature in VS2010?

    Have a nice day!

  4. markm@selacanada.ca says:

    I'm not sure if Web Essentials for VS2010 has the Paste as XML functionality. I don't have VS2010 install so I can't test. Sorry.

    Here's the link to the 2010 version for you to try: visualstudiogallery.msdn.microsoft.com/6ed4c78f-a23e-49ad-b5fd-369af0c2107f

    I do know, however, that it does not work for Visual Studio 2010 Express. The installer doesn't recognize that version.

  5. Juliano says:

    Thank you Mark for the link.

    I will test it and i back to tell you if it work.

    Thank you

Comments are closed.

Skip to main content