I am trying to convert a JSON to java object using using jackson. But I am getting null values. Here are my pojos. Please note that I have setters and getters on those 2 classes.
@JsonIgnoreProperties(ignoreUnknown = true)
public class IncidentDetails {
private Integer incidentTypeId;
private String description;
private List<IncidentEvents> incidentEventList;
@JsonIgnoreProperties(ignoreUnknown = true)
public class IncidentEvents {
private int eventId;
private int alarmId;
private Timestamp eventDateTime;
}
My Request:
{
"IncidentDetails": {
"incidentTypeId": "1",
"description": "Description",
"IncidentEvents":
[
{
"eventId": "1",
"alarmId": "1",
"eventDateTime": "09/29/2016 12:00:00 AM"
},
{
"eventId": "2",
"alarmId": "2",
"eventDateTime": "09/29/2016 12:05:00 AM"
}
]
}
}
And how I map it:
ObjectMapper mapper = new ObjectMapper();
IncidentDetails incident = mapper.readValue(details, IncidentDetails.class);
.....