title: Deserializing JSON with Child and Inner Childs
body: <p>I am familiar with JSON.net a bit and can Deserialize the JSON with basic structure (upto one child). I am currently in process of Deserializing the JSON that is returned from Netatmo API. The structure of JSON is complicated for me. Following is the basic structure of the JSON,</p>
  
  <pre><code>_id
  place
     location
          Dynamic Value 1
          Dynamic Value2
     altitude
     timezone
  mark
  measures
      Dynamic Value 1
      res
          Dynamic Value 1
                Dynamic Value 1
            Dynamic Value 2
      type
          Dynamic Value 1
          Dynamic Value 2
  modules
      Dynamic Value 1
  </code></pre>
  
  <p>Dynamic Value 1 and Dynamic Value 2 represents the values that is changed for each id. The complete JSON is given below,</p>
  
  <pre><code>{
      "body": [{
          "_id": "70:ee:50:02:b4:8c",
          "place": {
              "location": [-35.174779762001, -5.8918476117544],
              "altitude": 52,
              "timezone": "America\/Fortaleza"
          },
          "mark": 0,
          "measures": {
              "02:00:00:02:ba:2c": {
                  "res": {
                      "1464014579": [16.7, 77]
                  },
                  "type": ["temperature", "humidity"]
              },
              "70:ee:50:02:b4:8c": {
                  "res": {
                      "1464014622": [1018.1]
                  },
                  "type": ["pressure"]
              }
          },
          "modules": ["02:00:00:02:ba:2c"]
      }, {
          "_id": "70:ee:50:12:40:cc",
          "place": {
              "location": [-16.074257294385, 11.135715243973],
              "altitude": 14,
              "timezone": "Africa\/Bissau"
          },
          "mark": 14,
          "measures": {
              "02:00:00:06:7b:c8": {
                  "res": {
                      "1464015073": [26.6, 78]
                  },
                  "type": ["temperature", "humidity"]
              },
               "70:ee:50:12:40:cc": {
                  "res": {
                      "1464015117": [997]
                  },
                  "type": ["pressure"]
              }
          },
          "modules": ["02:00:00:06:7b:c8"]
      }],
      "status": "ok",
      "time_exec": 0.010364055633545,
      "time_server": 1464015560
  }
  </code></pre>
  
  <p>I am confused by looking at the complex structure of this JSON. For single level of JSON I have used this code in the past,</p>
  
  <pre><code>IList&lt;lstJsonAttributes&gt; lstSearchResults = new List&lt;lstJsonAttributes&gt;();
  foreach (JToken objResult in objResults) {
      lstJsonAttributes objSearchResult = JsonConvert.DeserializeObject&lt;lstJsonAttributes&gt;(objResult.ToString());
      lstSearchResults.Add(objSearchResult);
  }
  </code></pre>
  
  <p>But for so many child I have yet to understand how the object class will be created. Any guidance will highly appreciated.</p>
  
  <p>Update:
  This is what I have achieved so far.</p>
  
  <p>I have created a main class as below,</p>
  
  <pre><code>public class PublicDataClass
  {
      public string _id { get; set; }
      public PublicData_Place place { get; set; }
      public string mark { get; set; }
      public List&lt;string&gt; modules { get; set; }
  }
  </code></pre>
  
  <p>and "Place" class is as follow,</p>
  
  <pre><code>public class PublicData_Place
  {
      public List&lt;string&gt; location { get; set; }
      public string altitude { get; set; }
      public string timezone { get; set; }
  }
  </code></pre>
  
  <p>Then I have Deserialized the object in the following code line,</p>
  
  <pre><code>var obj = JsonConvert.DeserializeObject&lt;List&lt;PublicDataClass&gt;&gt;(jsonString);
  </code></pre>
  
  <p>I can now successfully get all the data except the "measures" which is little bit more complicated.</p>