title: Json.Net deserialize anonymous type
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2555363/deserializing-json-into-an-object-with-json-net">Deserializing JSON into an object with Json.NET</a>  </p>
  </blockquote>
  
  
  
  <p>Any ideas of how to deserialize the following response into anonymous type using Json.Net?</p>
  
  <pre><code>{"d":[{"day":"Wednesday","firstSet":{"start":"17:00","close":"23:00","hours":6,"isValid":true},"secondSet":{"start":"00:00","close":"00:00","hours":0,"isValid":false},"personMinimum":2,"personMaximum":25}]}
  </code></pre>
  
  <p>Attempts so far result in the following error</p>
  
  <p>Could not cast or convert from System.String to &lt;>f__AnonymousType3<code>5[System.String,&lt;&gt;f__AnonymousType2</code>4[System.String,System.String,System.Int32,System.Boolean],&lt;>f__AnonymousType2`4[System.String,System.String,System.Int32,System.Boolean],System.Int32,System.Int32].</p>
  
  <p>Code is supplied below</p>
  
  <pre><code>var json_complex = new
  {
    d = new
    {
      day = "",
      firstSet = new
      {
        start = "",
        close = "",
        hours = 0,
        isValid = false
      },
      secondSet = new
      {
        start = "",
        close = "",
        hours = 0,
        isValid = false
      },
      personMinimum = 2,
      personMaximum = 25
    }
  };
  var json = JsonConvert.DeserializeAnonymousType(jsonResponse, json_complex);
  </code></pre>
  
  <p>Any ideas?</p>