以下是我使用杰克逊转换为POJO的Json:
[
[
{
"title" : "Professional JavaScript",
"author" : "Nicholas C. Zakas"
},
{
"title" : "JavaScript: The Definitive Guide",
"author" : "David Flanagan
},
],
[
{
"title" : "High Performance JavaScript",
"author" : "Nicholas C. Zakas"
},
{
"title" : "Professional JavaScript",
"author" : "Nicholas C. Zakas"
},
{
"title" : "JavaScript: The Definitive Guide",
"author" : "Nicholas C. Zakas"
}
]
]
我收到以下错误
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.test.sample.jsonsample out of START_ARRAY token
以下是我的班级
public class jsonsample
{
@JsonProperty("title")
public String title;
@JsonProperty("author")
public String author;
//getters and setters
}
public class mainclass
{
public List<jsonsample> sjson;
}
ObjectMapper mapper = new ObjectMapper();
List<mainclass> accs = mapper.readValue(rspString,mapper.getTypeFactory().constructCollectionType(List.class, mainclass.class));
如何从嵌套结构以及未命名的数组中获取数据?