var bom = []; var Basket = []; fruitObj{}; fruitObj.fruit = "Apple"; fruitObj.quantity = "1"; Basket.push[fruitObj] fruitObj.fruit = "Grape"; fruitObj.quantity = "10"; Basket.push[fruitObj] JSON(bom.push[Basket]) -> received at server [[{\"fruit\":\"Apple\",\"quantity\":\"1\"},{\"fruit\":\"Grape\",\"quantity\":\"10\"}]]
Fruit.java
@JsonIgnoreProperties(ignoreUnknow = true) class Fruit(){ String fruit; String quantity; String price; //getters //setters } At Controller
List<List<?>> list = mapper.readValue(bom,TypeFactory.defaultInstance().constructCollectionType(List.class, FruitList.class)); FruitList.java
FruitList() { List<List<Fruit>> fruits; //getters (List<List<Fruit>>) //setters } I am facing org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance out of START_ARRAY token.
I have tried various combinations of List<>, List< List<> >, List< MyObjList >, MyObjList< Fruit > etc but unable to exactly parse it, however I am able to parse with mapper as List by passing Fruit.class for the below string [{\"fruit\":\"Apple\",\"quantity\":\"1\"},{\"fruit\":\"Grape\",\"quantity\":\"10\"}]