title: Deserializing JSON from Nest API into C# objects
body: <p>Trying to connect my custom .NET automation system to my Nest Thermostat.  I'm having a problem deserializing the JSON data and not all of populates into the classes.  I am not very versed with JSON or the NEST API so I hope I am approaching this correctly.  I am using Newtonsoft's JSON library.</p>
  
  <p>I started from the top and created a class that represents all the metadata.</p>
  
  <pre><code>public class All
  {
      public Dictionary&lt;string, Devices&gt; devices { get; set; }
      public Dictionary&lt;string, Structures&gt; structures { get; set; }
  }
  </code></pre>
  
  <p>I then created Structures Class</p>
  
  <pre><code>public class Structures
  {
      public Dictionary&lt;string, Structure&gt; structure { get; set; }
  }
  </code></pre>
  
  <p>and Devices class</p>
  
  <pre><code>public class Devices
  {
      public Dictionary&lt;string, Thermostats&gt; thermostats { get; set; }
  }
  </code></pre>
  
  <p>Also created the Structure</p>
  
  <pre><code>public class Structure
  {
      public string name { get; set; }
      public string country_code { get; set; }
      public string time_zone { get; set; }
      public string away { get; set; }
      public IList&lt;string&gt; thermostats { get; set; }
      public string structure_id { get; set; }
  }
  </code></pre>
  
  <p>and Thermostats</p>
  
  <pre><code>public class Thermostats
  {
      public Dictionary&lt;string, ThermostatDetails&gt; thermostatdetails { get; set; }
  }
  </code></pre>
  
  <p>and finally Thermostatdetails</p>
  
  <pre><code>public class ThermostatDetails
  {
      public int humidity { get; set; }
      public string locale { get; set; }
      public string temperature_scale { get; set; }
      public bool is_using_emergency_heat { get; set; }
      public bool has_fan { get; set; }
      public string software_version { get; set; }
      public bool has_leaf { get; set; }
      public string device_id { get; set; }
      public string name { get; set; }
      public bool can_heat { get; set; }
      public bool can_cool { get; set; }
      public string hvac_mode { get; set; }
      public double target_temperature_c { get; set; }
      public int target_temperature_f { get; set; }
      public double target_temperature_high_c { get; set; }
      public int target_temperature_high_f { get; set; }
      public double target_temperature_low_c { get; set; }
      public int target_temperature_low_f { get; set; }
      public double ambient_temperature_c { get; set; }
      public int ambient_temperature_f { get; set; }
      public double away_temperature_high_c { get; set; }
      public int away_temperature_high_f { get; set; }
      public double away_temperature_low_c { get; set; }
      public int away_temperature_low_f { get; set; }
      public string structure_id { get; set; }
      public bool fan_timer_active { get; set; }
      public string name_long { get; set; }
      public bool is_online { get; set; }
      public DateTime last_connection { get; set; }
  }
  </code></pre>
  
  <p>Once I've made the API call for All metadata and get the JSON back I am trying to deserialize with</p>
  
  <pre><code>Dim deserializedProduct As Nest.All = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Nest.All)(rawresp)
  </code></pre>
  
  <p>It does not throw any errors and seems to process fine.  In my case I only have 1 thermostat.  After it runs I see deserializedProduct.devices contains 1 and deserialize.structures contains 1.</p>
  
  <p>If I look at deserialize.structures(0) it has the structure key and the value shows as an empty Nest.Structure object meaning that it has no properties.</p>
  
  <p>If I look at deserializedProduct.devices it shows Thermostats class but no additional data below that.</p>
  
  <p>Has anyone been able to get such an approach working? Is the problem deserializing nested JSON?</p>
  
  <p>Any help or guidance is most appreciated.</p>