Paste JSON as Classes in Xamarin Studio

Update: Now compatible with Xamarin Studio/MonoDevelop 5

As a C# mobile developer I spend lot of time writing classes to serialise or deserialise JSON string when integrating apps with third-party REST APIs.Visual Studio has an amazing feature to rescue us from this tedious job, Paste JSON As Classes command, where it automatically generates the strongly typed classes for JSON string.

I was motivated to create a similar add-in for my primary development IDE, Xamarin Studio. I started writing the C# code generator with T4 templates, and quickly realised that it will take too long to finish the development with limited time I get to spend on side projects.

Luckily, I stumbled upon this awesome open source project on codeplex to generate the C# classes for JSON text. It supports typed arrays, typed objects, integers, floats, booleans, strings and nullable types. It helped me quickly put together an Add-in to paste JSON from clipboard to C# classes in Xamarin Studio

image

Installation

You need to follow these three easy steps to install it on our Xamarin Studio.

  1. Download the add-in package from Github
  2. Open Xamarin Studio -> Add-in Manager
  3. Click on Install from file… button and select the downloaded package to install

Once you install the add-in the Paste JSON as classes command will appear in Edit menu, that enable you to paste C# classes directly from the text in your clipboard.

The complete code for the add-in is available on the Github here, please add an issue if you find any bug or send me a pull request 🙂

8 thoughts on “Paste JSON as Classes in Xamarin Studio”

  1. I tried to install the add-in in Xamarin Studio 3.0 but it failed with error “The following dependencies cannot be resolved”:
    Monodevelop.Core v4.0
    Monodevelop.Ide v4.0

    1. I’m sorry, it is still not compatible with latest Xamarin studio. I will update the addin to make it compatible this weekend.

  2. I tried to install the add-in in Xamarin Studio 6.0 but it failed with error “The following dependencies cannot be resolved”:
    Monodevelop.Core v5.0
    Monodevelop.Ide v5.0

Leave a Reply

Your email address will not be published. Required fields are marked *