Newtonsoft JSON Deserialize Issue [Error converting value to type]
<p>Utilizing C# Newtownsoft JSON libraries... I have run into this issue.</p>

<p>To set the stage...</p>

<p>I have this JSON from a RESTful Web Service:</p>

<pre><code>[
    {
        "CorporateArea": "Brampton",
        "ServiceAddress": "321 Heart Lake Road",
        "VendorName": "Enbridge Gas Distribution Inc",
        "MeterNumber": "502105",
        "RateClass": "NG-R6",
        "Department": "22603",
        "Account": "12008",
        "VendorID": "0000001195",
        "MeterLevelID": 2882,
        "SiteAddressID": 468,
        "MappingLocation": "Beckett Sproule",
        "ElectricalBilling": "",
        "EnergyLine": "",
        "CorporateGroup": "Public Works"
    }
]
</code></pre>

<p>I also have these C# classes:</p>

<pre><code>public class AccountInfo
{
    [JsonProperty("Account")]
    public string Account { get; set; }

    [JsonProperty("CorporateArea")]
    public string CorporateArea { get; set; }

    [JsonProperty("CorporateGroup")]
    public string CorporateGroup { get; set; }

    [JsonProperty("Department")]
    public string Department { get; set; }

    [JsonProperty("ElectricalBilling")]
    public string ElectricalBilling { get; set; }

    [JsonProperty("EnergyLine")]
    public string EnergyLine { get; set; }

    [JsonProperty("MappingLocation")]
    public string MappingLocation { get; set; }

    [JsonProperty("MeterLevelID")]
    public string MeterLevelID { get; set; }

    [JsonProperty("MeterNumber")]
    public string MeterNumber { get; set; }

    [JsonProperty("RateClass")]
    public string RateClass { get; set; }

    [JsonProperty("ServiceAddress")]
    public string ServiceAddress { get; set; }

    [JsonProperty("SiteAddressID")]
    public string SiteAddressID { get; set; }

    [JsonProperty("VendorID")]
    public string VendorID { get; set; }

    [JsonProperty("VendorName")]
    public string VendorName { get; set; }
}

public class JSONArray {
   public IList&lt;AccountInfo&gt; AccountsInfo { get; set; }
}
</code></pre>

<p>From these, I call this Newtownsoft Method:</p>

<pre><code>JSONArray Accounts = JsonConvert.DeserializeObject&lt;JSONArray&gt; (responseBody,
   new JsonSerializerSettings
   {
      NullValueHandling = NullValueHandling.Ignore
   });
</code></pre>

<p>But everytime I do so, I get the exception Newtonsoft.Json.JsonSerializationException
with the error message:</p>

<blockquote>
  <p>Error converting value "[{"CorporateArea":"Brampton","ServiceAddress":"321 Heart Lake Road","VendorName":"Enbridge Gas Distribution Inc","MeterNumber":"502105","RateClass":"NG-R6","Department":"22603","Account":"12008","VendorID":"0000001195","MeterLevelID":2882,"SiteAddressID":468,"MappingLocation":"Beckett Sproule","ElectricalBilling":"","EnergyLine":"","CorporateGroup":"Public Works"}]" to type 'TestWebService_Consume.JSONArray'. Path '', line 1, position 421.</p>
</blockquote>

<p>I've tried messing with the JSON string so it's not an array, and casting it into a simple AccountsInfo object, it returns the same error.</p>

<p>I must be doing something wrong, but it's been some time since I've worked with the Newtonsoft JSON libraries, so I'm at a loss of what could possible be the issue here.</p>