title: Deserializing a dynamic type in JSON with .Net
body: <p>I have the following JSON:</p>
  
  <pre><code>\"success\":true,
     \"requestSecs\":0.084988117218,
     \"body\":{
        \"countsByStatus\":[
           {
              \"status\":\"yes\",
              \"counts\":{
                 \"byType\":{
                    \"fulltime\":0,
                    \"parttime\":0,
                    \"sub\":0,
                 },
                 \"total\":0
              }
           }
  </code></pre>
  
  <p>I am deserializing this into .net with the following classes:</p>
  
  <pre><code>[DataContract]
      public class ResponseAttendanceList
      {
          [DataMember(Name = "success")]
          public string Success;
  
          [DataMember(Name = "requestSecs")]
          public string RequestSecs;
  
          [DataMember(Name = "body")]
          public AttendanceList AttendanceList;
      }
  
  [DataContract]
      public class AttendanceList
      {
          [DataMember(Name = "countsByStatus")]
          public List&lt;Status&gt; countsByStatus;        
      }
  
  [DataContract]
      public class Status
      {
          [DataMember(Name = "status")]
          public string status;
  
          [DataMember(Name = "counts")]
          public Counts counts;
      }
  
  [DataContract]
      public class Counts
      {
          [DataMember(Name = "byType")]
          public ByType byType;
  
      }
  
  [DataContract]
      public class ByType
      {
          [DataMember(Name = "fulltime")]
          public int fulltime;
  
          [DataMember(Name = "parttime")]
          public int parttime;
  
          [DataMember(Name = "sub")]
          public int sub;
      }
  </code></pre>
  
  <p>The problem is, the types deserialized into the ByType class are actually dynamic, so can change.  How do I deserialize this JSON without knowing the types (fulltime, parttime, sub).  I tried to do this on the “Counts” class, but it didn’t work:</p>
  
  <pre><code>    [DataContract]
      public class Counts
      {        
          [DataMember(Name = "byType")]
          public KeyValuePair&lt;string, int&gt; byType;     
      }
  </code></pre>