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 into Java object and store it in List of java object. e.g. In Student object.
I am using below code to convert it into List of Java object : -
ObjectMapper mapper = new ObjectMapper();
StudentList studentList = mapper.readValue(jsonString, StudentList.class);
My List class is:-
public class StudentList {
private List<Student> participantList = new ArrayList<Student>();
//getters and setters
}
My Student object is: -
class Student {
String firstName;
String lastName;
//getters and setters
}
Am I missing something here?
I am getting below exception: -
Exception : com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.aa.Student out of START_ARRAY token
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…