Home
Do you know how to easily get classes from a JSON response?
  v2.0 Posted at 16/02/2015 4:05 PM by Damian Brady
​​When integrating with external Web APIs which return a JSON response, there is a quick and easy way to generate classes to handle that response.


Execute the request, and copy the text of the JSON response.

8-08-2014-3-41-23-PM-compressor.png

Create a new class in Visual Studio, and Click Edit | Paste Special | Past As JSON Classes and classes will be generated from the JSON in the clipboard.

8-08-2014-3-53-17-PM-compressor.png
Figure: Edit | Paste Special | Paste JSON As Classes

8-08-2014-3-56-34-PM-compressor.png
Figure: Classes generated from the JSON

The results may need cleaning up a little bit, but its much easier than trying to write them manually.


Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: