I have been trying to deserialize a json stirng. Do not understand where is the problem. It is throwing-
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of my.package.name.PlaceData[] out of START_OBJECT token
at [Source: java.io.StringReader@1fea1293; line: 1, column: 1]
My JSON string (placesData) is
{
"d":[
{
"__type":"my.package.name.PlaceData",
"Id":1212,
"Name":"Delhi",
"MeetingId":1211,
"Sessions":[]
},
{
"__type":"my.package.name.PlaceData",
"Id":8787,
"Name":"Bangalore",
"MeetingId":1211,
"SessionNames":[]
}
]
}
Java object is-
public class PlaceData {
public String __type;
public Integer Id;
public String Name;
public Integer MeetingId;
public SessionData[] sessionData=new SessionData[0];
public PlaceData() {
}
@Override
public String toString() {
return "PlaceData{" +
"__type='" + __type + '\'' +
", Id=" + Id +
", Name='" + Name + '\'' +
", MeetingId=" + MeetingId +
", SessionData=" + Arrays.toString(SessionData) +
'}';
} }
Deserialization code-
ObjectMapper mapper = new ObjectMapper();
List<PlaceData> placesList = Arrays.asList(mapper.readValue(placesData, PlaceData[].class));
Any clue??
It looks like you're deserializing an object rather than an array. The START_OBJECT token refers to the opening { bracket. You're actual data is accessible from propert 'd' of that object.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments