UPDATE: JSON Copy now available in Xamarin Studio’s Add-in Manager, under IDE Extensions
Few months back I published an Addin for MonoDevelop and Xamarin Studio to allow developer to paste JSON string as C# classes. The functionality was primitive and experimental, we did not have any control over the code formatting or class structure.
In v1.0 I have fixed most of those limitations in the Addin, now we have more control over how C# structured. You can find download and installation instruction here.
Here is what’s new in version 1.0:
- Choose between Pascal Casing and default lowercase letters
- Mark classes as
Fields for JSON properties.
- New Preferences Panel
I would love to hear your feedback, please create an issue in Github repo or leave a comment
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 🙂