Easiest way to parse JSON response

Follow these steps:

  1. Convert your JSON to C# using json2csharp.com;
  2. Create a class file and put the above generated code in there;
  3. Add the Newtonsoft.Json library to your project using the Nuget Package Manager;
  4. Convert the JSON received from your service using this code:

     RootObject r = JsonConvert.DeserializeObject<RootObject>(json);
    

(Feel free to rename RootObject to something more meaningful to you. The other classes should remain unchanged.)

Leave a Comment