title: How to parse / deserialize JSON returned from rest service in C#
body: <p>I am getting JSON in string format from a URL whose structure is like this, but I am unable to parse it. It's throwing an exception, any idea how to parse it?</p>
  
  <p>Here is the structure:</p>
  
  <pre><code>{
     "pathway":{
        "patients":{
           "patient":[
              {
                 "patientid":"7703176",
                 "name":"Abbot, Bud",
                 "status":"Invited",
                 "start":"2013-12-07",
                 "last":"N/A",
                 "engagement":"N/A",
                 "drug":"N/A",
                 "adherence":"N/A",
                 "vitals":"Current",
                 "last_appointment":"2013-10-25",
                 "next_appointment":"None"
              },
              {
                 "patientid":"5089554",
                 "name":"Brennan, Bonnie",
                 "status":"Connected",
                 "start":"2013-12-29",
                 "last":"2014-02-01",
                 "engagement":"Low",
                 "drug":" ",
                 "adherence":" ",
                 "vitals":"Out of Date",
                 "last_appointment":"2013-04-21",
                 "next_appointment":"None"
              }
           ]
        }
     }
  }
  </code></pre>
  
  <p>i am doing like this:</p>
  
  <pre><code>public class PathWayWrapper
  {
      public pathway pathway { get; set; }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class pathway
  {
      public List&lt;patient&gt; patients { get; set; }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class patient
  {
      public long patientid { get; set; }
      public string name { get; set; }
      public string status { get; set; }
      public string start { get; set; }
      public string last { get; set; }
      public string engagement { get; set; }
      public string drug { get; set; }
      public string adherence { get; set; }
      public string vitals { get; set; }
      public string last_appointment { get; set; }
      public string next_appointment { get; set; }
  }
  </code></pre>
  
  <p>here is my parsing code:</p>
  
  <pre><code>StreamReader reader = new StreamReader(response.GetResponseStream());
  
  string json = reader.ReadToEnd();
  
  var Jsonobject = JsonConvert.DeserializeObject&lt;PathWayWrapper&gt;(json);
  
  objPathway = Jsonobject.pathway;
  </code></pre>