【问题标题】:Can not deserialize instance of model class out of START_ARRAY token无法从 START_ARRAY 令牌中反序列化模型类的实例
【发布时间】:2016-12-09 08:43:22
【问题描述】:

我正在尝试将 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

我在哪里做错了?

【问题讨论】:

    标签: json spring-mvc


    【解决方案1】:

    使用jackson-databind jar。

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

    也请参考this

    【讨论】:

      猜你喜欢
      • 2020-09-23
      • 1970-01-01
      • 2015-01-04
      • 2016-07-30
      • 2015-03-10
      • 2019-10-25
      • 2015-12-24
      • 2018-12-03
      • 2020-07-07
      相关资源
      最近更新 更多