title: Parsing response in JSON
body: <pre><code>{
     "response":{
        "code":200,
        "message":"OK",
        "data":[
           {
              "user":{
                 "id":"564564",
                 "firstName":"XYZ",
                 "lastName":"J.",
                 "photo":"https:\/\/img-s.example.com\/userpix_thumbs\/48935_12545435354.png",
                 "gender":"male",
                 "homeCity":"Algonquin, IL",
                 "contact":{
  
                 }
              },
              "lastCheckin":34634543532
           },
           {
              "user":{
                 "id":"3254353",
                 "firstName":"PQR",
                 "lastName":"Black",
                 "photo":"https:\/\/img-s.example.com\/userpix_thumbs\/TJZE1FSTWBE5JA11.jpg",
                 "gender":"male",
                 "homeCity":"Chicago, IL",
                 "relationship":"friend",
                 "contact":{
  
                 }
              },
              "lastCheckin":3534523422345
           }
        ]
     }
  }
  </code></pre>
  
  <p>Above is the response in <code>JSON</code> . I am Not able to parse the “user” content from above response. It always returns <code>0</code>  instead of the <code>firstName</code> and <code>lastName</code> fields. Please Help. Below is my code.</p>
  
  <pre><code>FSQAPIRec_CheckIn_Results g1 = new FSQAPIRec_CheckIn_Results();
  
  HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  
  HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
  
  StreamReader sr = new StreamReader(resp.GetResponseStream());
  string json = sr.ReadToEnd();
  sr.Close();
  
  g1 = JSONHelper.Deserialise&lt;FSQAPIRec_CheckIn_Results&gt;(json);
  
  if (g1.response.message == "OK")
  {
  
      List&lt;FSQCheckIn_Data&gt; obj = g1.response.data;
  
      for (int i = 0; i &lt; obj.Count(); i++)
          {
              List&lt;FSQCheckIn_UserData&gt; obj1 = obj[i].user;
              for (int j = 0; j &lt; obj1.Count(); j++)
                  lbl_Resent_Chechin.Text += (j + 1) + ") " + obj1[j].firstName + " " + obj1[j].lastName + "&lt;br/&gt;&lt;br/&gt;";
          }
  }
  
  
  public class JSONHelper
  {
      public static T Deserialise&lt;T&gt;(string json)
      {
          using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
          {
              var serialiser = new DataContractJsonSerializer(typeof(T));
              return (T)serialiser.ReadObject(ms);
          }
      }
  
      public static string Serialize&lt;T&gt;(T obj)
      {
          DataContractJsonSerializer serializer = new      DataContractJsonSerializer(obj.GetType());
          using (MemoryStream ms = new MemoryStream())
          {
              serializer.WriteObject(ms, obj);
              return Encoding.Default.GetString(ms.ToArray());
          }
      }
  
  
  
  [Serializable]
  [DataContract]
  public class FSQAPIRec_CheckIn_Results
  {
      [DataMember]
      public RecCheckIn_Response response { get; set; }
  }
  [Serializable]
  [DataContract]
  public class RecCheckIn_Response
  {
      [DataMember]
      public string code { get; set; }
      [DataMember]
      public string message { get; set; }
      [DataMember]
      public List&lt;FSQCheckIn_Data&gt; data { get; set; }
  }
  [Serializable]
  [DataContract]
  public class FSQCheckIn_Data
  {
      [DataMember]
      public List&lt;FSQCheckIn_UserData&gt; user { get; set; }
  }
  [Serializable]
  [DataContract]
  public class FSQCheckIn_UserData
  {
      [DataMember]
      public string firstName { get; set; }
      [DataMember]
      public string lastName { get; set; }
      [DataMember]
      public string photo { get; set; }
  }
  </code></pre>