问题
使用postman向端发送请求时,出现
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `xxx` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `xxx` out of START_ARRAY token
原因
postman发送的特定字段为数组,但java object中该属性为对象,故序列化失败
办法
下面方案二选一
- 将postman中问题属性改为对象;
- 将java object中问题属性该为数组
在使用Postman向服务器发送请求时遇到一个问题,由于发送的数据中某个字段是个数组,而Java对象对应的属性是个对象,导致了JSON解析异常。解决这个问题的方法有两个:一是修改Postman中的字段类型,将其转换为对象;二是调整Java对象的设计,将该属性改为数组类型。选择其中一个方案即可避免序列化失败。

被折叠的 条评论
为什么被折叠?



