I need to parse the input json string into Java Object. I am using jackson annotation for that.
Input Json:-
{
"employee":{
"id":123,
"name":abc,
department:{
"id":123,
"name":"xyz"
}
}
}
Pojo File:-
public class Employee {
@JsonProperty("name")
protected String name;
@JsonProperty("department")
protected List<Department> departments;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Department> getDepartment() {
return departments;
}
public void setDepartment(List<Department> departments) {
this.departments = departments;
}
}
I am getting the below exception while using mapper.readValue(jsonString, Employee.class)
statement:
Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "employee"
if i use @JsonIgnoreProperties(ignoreUnknown=true)
nothing is getting mapped to my Employee object. Can anybody suggest what i am missing ?
Thanks,