This is my JSON array: -
[
{
"firstName" : "abc",
"lastName" : "xyz"
},
{
"firstName" : "pqr",
"lastName" : "str"
}
]
I have this in my String object. Now I want to convert it to a Java object and save it in a list of java objects. for example, in the Student object. I use the code below to convert it to a List of Java object: -
ObjectMapper mapper = new ObjectMapper();
StudentList studentList = mapper.readValue(jsonString, StudentList.class);
My list class: -
public class StudentList {
private List<Student> participantList = new ArrayList<Student>();
}
My Student object: -
class Student {
String firstName;
String lastName;
}
Am I missing something? I get below exceptions: -
Exception : com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.aa.Student out of START_ARRAY token
source
share