title: Put JSON data into c# datatable
body: <p>I am trying to deserialise some JSON that I get back from an API so that I can loop through an array of county names and add the information to a datatable in C#. However I am receiving following error at the first hurdle when I try and deserialise it: </p>
  
  <blockquote>
    <p>error: System.MissingMethodException: No parameterless constructor defined for type of 'DPDJSONLibrary.DPD_JSON+LOCR_Data[]'.</p>
  </blockquote>
  
  <p>The provider of the API provides an example of the JSON response as follows:</p>
  
  <pre><code>{
      "error": null,
      "data":[{
          "country": [{
              "countryCode":"GB",
              "countryName":"United Kingdom",
              "internalCode":"UK",
              "isEUCountry":false,
              "isLiabilityAllowed":false,
              "isoCode":"826",
              "isPostcodeRequired":false,
              "liabilityMax":15000
          }]
      }]
  }
  </code></pre>
  
  <p>A sample of the JSON data I am getting back from the API is:</p>
  
  <pre><code>{
      "data": {
          "country":[
              {
                  "countryCode":"PM",
                  "countryName":"St Pierre &amp; Miquilon",
                  "isoCode":"666",
                  "isEUCountry":false,
                  "isLiabilityAllowed":true,
                  "liabilityMax":15000,
                  "isPostcodeRequired":true
              },
              {
                  "countryCode":"SR",
                  "countryName":"Suriname",
                  "isoCode":"740",
                  "isEUCountry":false,
                  "isLiabilityAllowed":true,
                  "liabilityMax":15000,
                  "isPostcodeRequired":true
              },
              {
                  "countryCode":"SZ",
                  "countryName":"Swaziland",
                  "isoCode":"748",
                  "isEUCountry":false,
                  "isLiabilityAllowed":true,
                  "liabilityMax":15000,
                  "isPostcodeRequired":true
              }
          ]
      }
  }
  </code></pre>
  
  <p>I have tried to make some classes to put the JSON in as follows:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// List Of Countries Response object.
  /// &lt;/summary&gt;
  public class LOCR
  {
      public LOCR_Error error { get; set; }
      public LOCR_Data[] data { get; set; }
  }
  
  public class LOCR_Error
  {
      public string errorAction { get; set; }
      public string errorCode { get; set; }
      public string errorMessage { get; set; }
      public string errorObj { get; set; }
      public string errorType { get; set; }
  }
  
  public class LOCR_Data
  {
      public LOCR_Data_Country[] country { get; set; }
  }
  
  public class LOCR_Data_Country
  {
      public string countryCode { get; set; }
      public string countryName { get; set; }
      public string internalCode { get; set; }
      public bool isEUCountry { get; set; }
      public bool isLiabilityAllowed { get; set; }
      public string isoCode { get; set; }
      public bool isPostcodeRequired { get; set; }
      public int liabilityMax { get; set; }
  }
  </code></pre>
  
  <p>When I get the JSON back as a string, I am trying to use the Newtonsoft (plugin?) to put it into my classes using:</p>
  
  <pre><code>JavaScriptSerializer ser = new JavaScriptSerializer();
  DPD_JSON.LOCR DPDCountries = new DPD_JSON.LOCR();
  DPDCountries = ser.Deserialize&lt;DPD_JSON.LOCR&gt;(data);
  </code></pre>
  
  <p>It is the last line above that is generating the error. I suspect I've written my classes wrong that I am trying to deserialise the JSON in to - can anyone see where I've gone wrong?</p>