Creating a Merged Model Using Glue API
3D Web Viewing Technologies from Recent Meetups

JSON to C# Class Generator

Here is yet another tool that you might find useful if you are working with REST API, serializing and deserializing a lot. json2csharp (http://json2csharp.com/) is an online tool which generates C# classes from a given JSON string. You can take any JSON string, copy and paste to the web page, and with a click of button, you get the definition of classes automatically generated.

As an example, suppose you are using Field API Intro labs. You get a long list of response string in Response textbox. Copy that string into a textbox on the http://json2csharp.com page. Then click “Generate” button. Voila, you get class definitions instantly. The image below shows an example when I copied a response of Field issue list: 

Json2csharp2

I bumped into this tool while searching a REST related topic on the Internet. Before I encountered this tool, I was trying to figure out classes from sample responses. It was a tedious task, and I was feeling a bit bored. I was very happy when I encountered this tool. You may still need to tweak the result. But it's nothing compared with the tasks of dissecting long list of un-formatted JSON string and trying to figure out the classes. We still have lots of undocumented Field REST methods. This will be my friend for some time :-) 

This is based on the open source project called "JSON C# Class Generator", and hosted at CodePlex. You can find more information here: http://jsonclassgenerator.codeplex.com/

Mikako

Comments