title: Retrofit | Parsing nested JSON objects ("Expected BEGIN_ARRAY but was BEGIN_OBJECT at...)
body: <p>I'm trying to parse this JSON into a POJO, but I'm getting an error </p>
  
  <blockquote>
    <p>"Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2"</p>
  </blockquote>
  
  <p>I believe that the problem is caused because I have nested JSON objects and json arrays. Here's what the JSON I'm trying to parse looks like:</p>
  
  <pre><code>[
     {
        "id":"3",
        "table":{
           "id":"1",
           "number":"1",
           "seats":"2",
           "description":"Vereda"
        },
        "user_id":"1",
        "status":null,
        "created_at":{
           "date":"2014-05-21 20:46:36",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "updated_at":{
           "date":"2014-05-21 20:46:36",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "items":[
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"2",
              "description":"dulce",
              "name":"Medialuna",
              "price":"3.75"
           },
           {
              "id":"2",
              "description":"dulce",
              "name":"Medialuna",
              "price":"3.75"
           }
        ]
     },
     {
        "id":"5",
        "table":{
           "id":"2",
           "number":"2",
           "seats":"4",
           "description":"Mesa grande"
        },
        "user_id":"1",
        "status":null,
        "created_at":{
           "date":"2014-05-21 20:49:21",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "updated_at":{
           "date":"2014-05-21 20:49:21",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "items":[
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           }
        ]
     },
     {
        "id":"6",
        "table":{
           "id":"5",
           "number":"5",
           "seats":"2",
           "description":null
        },
        "user_id":"1",
        "status":null,
        "created_at":{
           "date":"2014-05-21 20:51:12",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "updated_at":{
           "date":"2014-05-21 20:51:12",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "items":[
           {
              "id":"1",
              "description":"",
              "name":"Caf\u00e9 mediano",
              "price":"8.5"
           },
           {
              "id":"2",
              "description":"dulce",
              "name":"Medialuna",
              "price":"3.75"
           }
        ]
     },
     {
        "id":"7",
        "table":{
           "id":"1",
           "number":"1",
           "seats":"2",
           "description":"Vereda"
        },
        "user_id":"1",
        "status":null,
        "created_at":{
           "date":"2014-05-22 02:09:30",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "updated_at":{
           "date":"2014-05-22 02:09:30",
           "timezone_type":3,
           "timezone":"UTC"
        },
        "items":[
  
        ]
     }
  ]
  </code></pre>
  
  <p>As you can see, each object "ORDER" has nested objects like "Item" "Table" etc. Here are my respective Java Classes</p>
  
  <p><strong>Order.class</strong></p>
  
  <pre><code>public class Order {
  
      private int id;
      private Table table;
      private int user_id;
      private Date created_at;
      private Date updated_at;
  
      //GETTERS AND SETTERS....
  
  }
  </code></pre>
  
  <p><strong>Table.class</strong></p>
  
  <pre><code>public class Table {
  
      private int id;
      private String description;
      private int seats;
      private int number;
  
      //GETTERS AND SETTERS...    
  
  }
  </code></pre>
  
  <p><strong>Item.class</strong></p>
  
  <pre><code>public class Item {
  
  
      private int id;
      private String description;
      private String name;
      private double price;
  
     //GETTERS AND SETTERS...
  }
  </code></pre>
  
  <p><strong>Date.class</strong></p>
  
  <pre><code>public class Date {
  
      private String date;
      private int timezone_type;
      private String UTC; //GETTERS AND SETTERS...
  }
  </code></pre>
  
  <p>I'm calling a retrofit through an interface like this:</p>
  
  <pre><code>@GET(Constants.URL_ORDERS)
  public List&lt;Order&gt; retreiveOrders();
  </code></pre>
  
  <p>I don't know what I'm doing wrong :/</p>