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
You need to follow these three easy steps to install it on our Xamarin Studio.
- Download the add-in package from Github
- Open Xamarin Studio -> Add-in Manager
- 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 🙂