title: Using JSON.net to deserialize a list of nested objects
body: <p>Thanks in advance for your help. </p>
  
  <p>I have a JSON file that contains a list of nested objects. Using the code below - I get an exception on the call to DeserializeObject. We are using JSON.net</p>
  
  <p>Any help is appreciated</p>
  
  <p>JSON: </p>
  
  <pre><code>[
      {
          "Email": "james@example.com",
          "Active": true,
          "CreatedDate": "2013-01-20T00:00:00Z",
          "Input": {
              "User": "Jim",
              "Admin": "John"
          },
          "Output": {
              "Version": "12345",
              "Nylon": "None"
          }
      },
  
          {
          "Email": "bob@example.com",
          "Active": true,
          "CreatedDate": "2013-01-21T00:00:00Z",
          "Input": {
              "User": "Bob",
              "Admin": "John"
          },
          "Output": {
              "Version": "12399",
              "Nylon": "134"
          }
      }
  ]
  </code></pre>
  
  <p>To support the deserialization I have created the following class structure. </p>
  
  <pre><code>public class Test002
      {
          public class Input
          {
              public string User { get; set; }
              public string Admin { get; set; }
          }
  
          public class Output
          {
              public string Version { get; set; }
              public string Nylon { get; set; }
          }
  
          public class RootObject
          {
              public string Email { get; set; }
              public bool Active { get; set; }
              public DateTime CreatedDate { get; set; }
              public Input input { get; set; }
              public Output output { get; set; }
          }
  
          public class TestCases
          {
              public List&lt;RootObject&gt; rootObjects { get; set; }
          }
  
      }
  </code></pre>
  
  <p>And finally here is the call to JSON.net JsonConvert.DeserializeObject - throws the following exception. </p>
  
  <pre><code>Test002.TestCases tTestCases = JsonConvert.DeserializeObject&lt;Test002.TestCases&gt;(File.ReadAllText(@"C:\test\Automation\API\Test002.json"));
  </code></pre>
  
  <p>I think I need something like this - to deseralize the list of objects - The code below fails</p>
  
  <pre><code>    Test002.TestCases tTestCases = JsonConvert.DeserializeObject&lt;IList&lt;Test002.TestCases&gt;&gt;(File.ReadAllText(@"C:\test\Automation\API\Test002.json"));
  </code></pre>
  
  <p>Exception: </p>
  
  <p>An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code</p>
  
  <p>Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'APISolution.Test002+TestCases' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.</p>
  
  <p>To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.</p>
  
  <p>Path '', line 1, position 1.</p>