title: Deserializing JSON with nested arrays with Jackson
body: <p>I am trying to deserialize JSON data into a custom class. I am having trouble getting the nested array to deserialize properly, throwing an exception. I have looked into various Jackson annotations but I haven't seen anything that might help.</p>
  
  <p>JSON:</p>
  
  <pre><code>{
  "purchaseOrderLines": [
      {
          "jsId": 1,
          "part": 26,
          "partNumber": "MS-12345",
          "quantityOrdered": "1000",
          "price": ".50",
          "unit": "EACH",
          "dueDate": "2013-12-31",
          "requirements": [
              [
                  {
                      "requirement": "degrease",
                      "price": "25",
                      "jsId": 0
                  }
              ]
          ],
          "class": "purchaseOrder.PurchaseOrderLine"
      }
  ],
  "vendor": "39",
  "shipper": "53",
  "shipMethod": "3",
  "vendorSalesman": "41"
  }
  </code></pre>
  
  <p>PurchaseOrder.java</p>
  
  <pre><code>package purchaseOrder;
  
  import java.util.ArrayList;
  import java.util.List;
  import models.addressBook.*;
  import play.db.jpa.Model;
  
  public class PurchaseOrder extends Model{
      public Vendor vendor;
      public Contact vendorSalesman;
      public Shipper shipper;
      public ShipMethod shipMethod;
      public String notes;
      public List&lt;PurchaseOrderLine&gt; purchaseOrderLines= new ArrayList&lt;PurchaseOrderLine&gt;();
      public List&lt;Requirement&gt; globalRequirements= new ArrayList&lt;Requirement&gt;();
  }
  </code></pre>
  
  <p>PurchaseOrderLine.java</p>
  
  <pre><code>package purchaseOrder;
  
  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;   
  import java.math.BigDecimal;
  import java.util.ArrayList;
  import java.util.List;
  import models.inventory.Part;
  import org.joda.time.DateTime;
  import org.joda.time.format.ISODateTimeFormat;
  import purchaseOrder.util.UnitType;
  
  @JsonIgnoreProperties(ignoreUnknown = true)
  public class PurchaseOrderLine {
  
      public Part part;
      public Long quantityOrdered;
      public BigDecimal price;
      public UnitType unit;
      public DateTime dueDate;
      public List&lt;Requirement&gt; requirements= new ArrayList&lt;Requirement&gt;();
  
      public void setDueDate(String dueDate)
      {
          this.dueDate = ISODateTimeFormat.date().parseDateTime(dueDate);
      }
  }
  </code></pre>
  
  <p>Requirement.java</p>
  
  <pre><code>package purchaseOrder;
  
  import com.fasterxml.jackson.annotation.*;
  import play.db.jpa.Model;
  
  @JsonIgnoreProperties(ignoreUnknown = true)
  
  public class Requirement extends Model
  {
       public String requirement;
       public String price;
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of purchaseOrder.Requirement out of START_ARRAY token
   at [Source: java.io.StringReader@7fc99326; line: 1, column: 160] (through reference chain: PurchaseOrder["purchaseOrderLines"]-&gt;PurchaseOrderLine["requirements"])
          at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:163)
          at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:588)
          at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:582)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromArray(BeanDeserializer.java:512)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:129)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:226)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:203)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
          at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:336)
          at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:87)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:290)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:226)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:203)
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
          at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:336)
          at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:87)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:290)
          at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112)
          at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2580)
          at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1810)
          at controllers.PurchaseOrderController.submitQuote(PurchaseOrderController.java:24)
          at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:557)
          at play.mvc.ActionInvoker.invoke(ActionInvoker.java:508)
          at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
          at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
          at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
          ... 1 more
  </code></pre>
  
  <p>I know that deserializing the requirement class is good as I can deserialize the globalRequirements without problem. I can also deserialize fine if I omit the requirements of the purchaseOrderLine. Thanks for any help/pointers you can give</p>