C# and JSON

If you need to use data formatted with the JSON standard, here is a simple trick to get started (but you can complicate it as you wish ;)). I use the Web Essentials extension and the NuGet package Json.NET. The JSON data file I use is this one: Example JSON File (source).

Here are the steps to take the JSON data, generate the necessary classes, download the data, and populate these new classes:

  • Install the Web Essentials extension
  • Create a new class file
  • Put a snippet or the entire JSON data into the clipboard (Copy or CTRL-C)
  • Right-click in the editor or go to the EDIT menu/Special Paste and select “Paste JSON as Classes”

image

[Read More]