title: Deserializing Import Io JSON with multiple objects
body: <p>Morning all,</p>
  
  <p>Im using Newtonsoft.JSON to deserialize a JSON response from Import Io. I have successfully used <a href="http://json2csharp.com/" rel="nofollow">http://json2csharp.com/</a> to build a data model successfully in one instance to gain access to the data, however in that instance only one JSON object was returned. I am now working on a new piece of JSON that is being returned with multiple objects and i'm hitting issues with the following error message:</p>
  
  <p>Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[OSP.Shop_DTO+RootObject]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
  To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
  Path 'url', line 1, position 7."</p>
  
  <p><strong>My JSON looks like this:</strong></p>
  
  <pre><code>{
      "url": "http://www.myurl.com/-shop-item.html",
      "result": {
          "extractorData": {
              "url": "http://www.myurl.com/-shop-item.html",
              "resourceId": "1db49f66afc2f234cb5ab470f0c39e0c",
                  "data": [
                  {
                      "group": [
                          {
                              "BN_shop_1KG": [
                                  {
                                      "text": "$36.00"
                                  }
                              ],
                              "BN_shop_2KG": [
                                  {
                                      "text": "$69"
                                  }
                              ],
                              "BN_shop_3KG": [
                                  {
                                      "text": "$97"
                                  }
                              ],
                              "BN_VEGE_5KG": [
                                  {
                                      "text": "3 KG = $97"
                                  }
                              ],
                              "BN_shop_4KG": [
                                  {
                                      "text": "$124"
                                  }
                              ],
                              "BN_shop_5KG": [
                                  {
                                      "text": "$149"
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          "pageData": {
              "resourceId": "1db49f66afc2f234cb5ab470f0c39e0c",
              "statusCode": 200,
              "timestamp": 1476432605275
          },
          "timestamp": 1476432606594,
          "sequenceNumber": 0
      }
  }{
      "url": "http://www.myurl.com/-shop-concentrate.html",
      "result": {
          "extractorData": {
              "url": "http://www.myurl.com/-shop-concentrate.html",
              "resourceId": "dd4837cc7d0085eae005243c7bd8ca8a",
              "data": [
                  {
                      "group": [
                          {
                              "BN_shop_1KG": [
                                  {
                                      "text": "$27.00"
                                  }
                              ],
                              "BN_shop_2KG": [
                                  {
                                      "text": "$49"
                                  }
                              ],
                              "BN_shop_3KG": [
                                  {
                                      "text": "$69"
                                  }
                              ],
                              "BN_VEGE_5KG": [
                                  {
                                      "text": "3 KG = $69"
                                  }
                              ],
                              "BN_shop_4KG": [
                                  {
                                      "text": "$84"
                                  }
                              ],
                              "BN_shop_5KG": [
                                  {
                                      "text": "$99"
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          "pageData": {
              "resourceId": "dd4837cc7d0085eae005243c7bd8ca8a",
              "statusCode": 200,
              "timestamp": 1476432604237
          },
          "timestamp": 1476432605124,
          "sequenceNumber": 1
      }
  }{
      "url": "http://www.myurl.comshop-matrix.html",
      "result": {
          "extractorData": {
              "url": "http://www.myurl.comshop-matrix.html",
              "resourceId": "deee30ffa0098e017a06c0e0c805e133",
              "data": [
                  {
                      "group": [
                          {
                              "BN_shop_1KG": [
                                  {
                                      "text": "$29.00"
                                  }
                              ],
                              "BN_shop_2KG": [
                                  {
                                      "text": "$56"
                                  }
                              ],
                              "BN_shop_3KG": [
                                  {
                                      "text": "$79"
                                  }
                              ],
                              "BN_VEGE_5KG": [
                                  {
                                      "text": "3 KG = $79"
                                  }
                              ],
                              "BN_shop_4KG": [
                                  {
                                      "text": "$99"
                                  }
                              ],
                              "BN_shop_5KG": [
                                  {
                                      "text": "$119"
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          "pageData": {
              "resourceId": "deee30ffa0098e017a06c0e0c805e133",
              "statusCode": 200,
              "timestamp": 1476432602408
          },
          "timestamp": 1476432603204,
          "sequenceNumber": 2
      }
  }{
      "url": "http://www.myurl.comsoy-shop-item.html",
      "result": {
          "extractorData": {
              "url": "http://www.myurl.comsoy-shop-item.html",
              "resourceId": "5593aad40f95ba868626e47a1b550813",
              "data": [
                  {
                      "group": [
                          {
                              "BN_shop_1KG": [
                                  {
                                      "text": "$25.00"
                                  }
                              ],
                              "BN_shop_2KG": [
                                  {
                                      "text": "$45"
                                  }
                              ],
                              "BN_shop_3KG": [
                                  {
                                      "text": "$89"
                                  }
                              ],
                              "BN_VEGE_5KG": [
                                  {
                                      "text": "5 KG = $89"
                                  }
                              ],
                              "BN_shop_4KG": [
                                  {
                                      "text": "$175"
                                  }
                              ],
                              "BN_shop_5KG": [
                                  {
                                      "text": "$339"
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          "pageData": {
              "resourceId": "5593aad40f95ba868626e47a1b550813",
              "statusCode": 200,
              "timestamp": 1476432602479
          },
          "timestamp": 1476432603847,
          "sequenceNumber": 3
      }
  }{
      "url": "http://www.myurl.compea-shop.html",
      "result": {
          "extractorData": {
              "url": "http://www.myurl.compea-shop.html",
              "resourceId": "f91e05d0265ab5a5f7f948c57a05bced",
              "data": [
                  {
                      "group": [
                          {
                              "BN_shop_1KG": [
                                  {
                                      "text": "$25.00"
                                  }
                              ],
                              "BN_shop_2KG": [
                                  {
                                      "text": "$45"
                                  }
                              ],
                              "BN_shop_3KG": [
                                  {
                                      "text": "$89"
                                  }
                              ],
                              "BN_VEGE_5KG": [
                                  {
                                      "text": "5 KG = $89"
                                  }
                              ],
                              "BN_shop_4KG": [
                                  {
                                      "text": "$169"
                                  }
                              ],
                              "BN_shop_5KG": [
                                  {
                                      "text": "$319"
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          "pageData": {
              "resourceId": "f91e05d0265ab5a5f7f948c57a05bced",
              "statusCode": 200,
              "timestamp": 1476432605227
          },
          "timestamp": 1476432606451,
          "sequenceNumber": 4
      }
  }
  </code></pre>
  
  <p><strong>Model looks like this:</strong></p>
  
  <pre><code>public class BNShop1KG
  {
      public string text { get; set; }
  }
  
  public class BNShop2KG
  {
      public string text { get; set; }
  }
  
  public class BNShop3KG
  {
      public string text { get; set; }
  }
  
  public class BNVEGE5KG
  {
      public string text { get; set; }
  }
  
  public class BNShop4KG
  {
      public string text { get; set; }
  }
  
  public class BNShop5KG
  {
      public string text { get; set; }
  }
  
  public class Group
  {
      public List&lt;BNShop1KG&gt; BN_shop_1KG { get; set; }
      public List&lt;BNShop2KG&gt; BN_shop_2KG { get; set; }
      public List&lt;BNShop3KG&gt; BN_shop_3KG { get; set; }
      public List&lt;BNVEGE5KG&gt; BN_VEGE_5KG { get; set; }
      public List&lt;BNShop4KG&gt; BN_shop_4KG { get; set; }
      public List&lt;BNShop5KG&gt; BN_shop_5KG { get; set; }
  }
  
  public class Datum
  {
      public List&lt;Group&gt; group { get; set; }
  }
  
  public class ExtractorData
  {
      public string url { get; set; }
      public string resourceId { get; set; }
      public List&lt;Datum&gt; data { get; set; }
  }
  
  public class PageData
  {
      public string resourceId { get; set; }
      public int statusCode { get; set; }
      public long timestamp { get; set; }
  }
  
  public class Result
  {
      public ExtractorData extractorData { get; set; }
      public PageData pageData { get; set; }
      public long timestamp { get; set; }
      public int sequenceNumber { get; set; }
  }
  
  public class RootObject
  {
      public string url { get; set; }
      public Result result { get; set; }
  }
  </code></pre>
  
  <p>In my code i'm trying to get access to the 'text' value in 'BN_shop_1KG' from the first JSON object. This item:</p>
  
  <pre><code>"BN_shop_1KG": [
     {
          "text": "$36.00"
     }
  </code></pre>
  
  <p><strong>I've tried the following in my code, but am receiving the error outlined above. From what I understand reading some previous threads about this is that I will need to use a deserialize into List to handle JSON received in this manner:</strong></p>
  
  <pre><code>    List&lt;Shop_DTO.RootObject&gt; obj = JsonConvert.DeserializeObject&lt;List&lt;Shop_DTO.RootObject&gt;&gt;(_rawHtmlResult);
  
      var price = obj.First().result.extractorData.data[0].group[0].BN_shop_1kg[0].text;
      Debug.WriteLine("Price for item {0}", price);
  </code></pre>
  
  <p>Any help would be hugely appreciated, i've been stuck on this for a couple of days :(</p>