Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

Wednesday, 24 August 2016

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

When supplying json object from postman. if Class contain a list object. Provide it as a array [].
ex :
{
    "name" : "raman",
    "employeeId" : 12345,
"orderList" : {"orderId" : 1,"orderName" : "rest json book"}
}
solution :
{
"name" : "raman",
"employeeId" : 12345,
"orderList" : [{"orderId" : 1,"orderName" : "rest json book"}]
}

@JsonIgnore

@JsonIgnore

If we want to serialize object to json, during this process some of the property can be null/empty can be ignored.
this can be achived using @jsonIgnore.

ex :
1. @JsonIgnore(Include.NON_NULL)
2. @JsonIgnore(Include.NON_EMPTY)
3. @JsonIgnore(Include.NON_DEFAULT)

Ref : wilddiary

use of @JsonSerialize

use of @JsonSerialize

A pojo class which is participating is serialisationtion should be annoted with @JsonSerialize