title: Error deserializing JSON with Newtonsoft, C#
body: <p>I'm receiving the following error: </p>
  
  <blockquote>
  <pre><code>Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.List`1[ReportingDataSchema.CurrentBusinessUnits]]' 
  because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly. 
  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&lt;T&gt; 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. Path 'selectedBusinessUnits', line 1, position 26."} System.Exception {Newtonsoft.Json.JsonSerializationException}
  </code></pre>
  </blockquote>
  
  <p>My JSON:</p>
  
  <pre class="lang-js prettyprint-override"><code>{
    "selectedBusinessUnits": [{
      "guidNode": "some value",
      "businessUnit": "some value",
      "fileName": "some value"
    }, {
      ...
    }]
  }
  </code></pre>
  
  <p>I'm trying to first transform this response into the following: </p>
  
  <pre class="lang-c# prettyprint-override"><code>public class EnAFileGenerator
  {
      private Dictionary&lt;string, List&lt;CurrentBusinessUnits&gt;&gt; selectedBusinessUnits;
  
      public Dictionary&lt;string, List&lt;CurrentBusinessUnits&gt;&gt; SelectedBusinessUnits 
      {
          get { return selectedBusinessUnits; }
          set { selectedBusinessUnits = value; }
      }
  }
  </code></pre>
  
  <p>So that ultimately I can access the array in the JSON, using the following:</p>
  
  <pre class="lang-c# prettyprint-override"><code>public class CurrentBusinessUnits
  {
      private string guidNode;
      private string businessUnit;
      private string fileName;
  
      public string GuidNode { get; set; }
      public string BusinessUnit { get; set; }        
      public string FileName { get; set; }       
  }
  </code></pre>
  
  <p>The code that's generating the error:</p>
  
  <pre><code>// JSON Data is the parameter from the client, containing the above JSON object
  EnAFileGenerator resultArray = JsonConvert.DeserializeObject&lt;EnAFileGenerator&gt;(JSONData);
  </code></pre>
  
  <p>From what I've read, it seems like my error is a result of the parsing the array (the value for the property <code>selectedBusinessUnits</code>) into the desired <code>C#</code> collection. </p>
  
  <p>After implementing @DavidG's suggestion, I'm still receiving the following:</p>
  
  <pre><code>Error converting value \"{\"guidNode\":\"some value\",\"businessUnit\":\"some value\",\"fileName\":\"some value.xlsx\"}\" 
  to type 'ReportingDataSchema.CurrentBusinessUnits'. Path 'selectedBusinessUnits[0]', line 1, position 159."}    
  System.Exception {Newtonsoft.Json.JsonSerializationException}
  </code></pre>
  
  <p>Prany's solution nearly got me there. I was able to modify that code to utilize the objects I already had:</p>
  
  <pre><code>var files = JObject.Parse(JSONData);
  var recList = files.SelectToken("$..selectedBusinessUnits").ToList();
  
  foreach (string item in recList)
  {
      JObject businessUnit = JObject.Parse(item);
  
      CurrentBusinessUnits currentBusinessUnit = businessUnit.ToObject&lt;CurrentBusinessUnits&gt;();
  }
  </code></pre>