无法从START_ARRAY标记中反序列化模型类的实例

时间:2016-12-09 08:43:22

标签: json spring-mvc

我正在尝试将json数组列表数据发布到spring rest调用并执行我的逻辑,如下所示

模特课程:

public class ABCDEF{

private String A;
private String B;
private ArrayList<Long> C;
private ArrayList<Long> D;
private ArrayList<String> E;
private String F;

//getter //setter
}

休息电话:

@RequestMapping(value="/post/data", method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
public List<ModelClass1> retrieveData(@RequestBody List<ABCDEF> dataFromUser){

return null;

}

输入尝试:

[
{
"A" : "something",    
"B":"something",   
"C":[1],
"D": [1,2],
"E":["123","1234"],
"F":"something"
},
{
"A" : "something",    
"B":"something",   
"C":[4,5],
"D": [7,8,9],
"E":["1111","9999"],
"F":"something"
}
]

但它抛出异常,

nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.ABCDEF out of START_ARRAY token

我在哪里做错了?

1 个答案:

答案 0 :(得分:1)

使用jackson-databind jar。

你可能已经看过异常,然后你可以参考this,说这个问题在Spring 3.2中得到了解决。

请参阅this