Technology, Smartphones, Games


How to convert JSON Text to C# Class

How to convert JSON Text to CSharp Class

While making an API (Application programming interface) call, the response may be JSON (JavaScript Object Notation). If you want to convert them to C# class for easier access, you will have to create C# Class matching the JSON response. If the result is a simple JSON it may be easy to create C# Class. But the response is a complex one, the class generation may be time consuming.

Just introducing a web site and a windows application, they will help you to create C# class from JSON response.

json2csharp

How to convert JSON Text to CSharp Class

Just open the website http://json2csharp.com/  paste the JSON text (or you can use the URL of the JSON) and click Generate. The class or Classes will be generated based on the text.

jsonclassgenerator

jsonclassgenerator is an open source windows application which also does the same. It have some more features. The screenshot of the application is at the top of this page. You can get it from https://archive.codeplex.com/?p=jsonclassgenerator or from gitHub https://github.com/antiufo/json-class-generator (It currently supports typed arrays, typed objects, integers, floats, booleans, strings and nullable types.)