0. 报错信息 “JSON parse error: Cannot deserialize value of type java.util.ArrayList from String value (t
“JSON parse error: Cannot deserialize value of type java.util.ArrayList
from String value (token jsonToken.VALUE_STRING
); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.util.ArrayList
from String value (token JsonToken.VALUE_STRING
)\n at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 6, column: 13] (through reference chain: com.ruoyi.wx.vo.WxHdVo[“yhzp”])”
WxHdVo.java
public class WxHdVo implements Serializable { private String sbr; private String yhdd; private String yhbw; private String yhms; private List<ScHdImg> yhzp;}
WxHdController.java
@Controller@RequestMapping("/wx/hd")public class WxHdController { @Autowired private IScHdService scHdService; @Autowired private IScHdImgService scHdImgService; @PostMapping("/add") @ResponseBody public String addHdFromWx(@RequestBody WxHdVo wxHdVo) { ScHd scHd = new ScHd(wxHdVo.getSbr(), wxHdVo.getYhdd(), wxHdVo.getYhbw(), wxHdVo.getYhms()); scHdService.insertScHd(scHd); Long scHdId = scHd.getId(); for (ScHdImg hdImg : wxHdVo.getYhzp()) { scHdImgService.insertScHdImg(new ScHdImg(scHdId, hdImg.getUrl(), new Date(), "1")); } return "success"; }}
发送请求的Body
{ "sbr": "xinglibao", "yhdd": "绿地世纪城", "yhbw": "一号消防通道", "yhms": "消防通道被堵塞", "yhzp": "[{'url': 'haha'}, {'url': 'heihei'}]"}
在百度搜索后发现是自己的 json 写错了,应将"yhzp": "[{'url': 'haha'}, {'url': 'heihei'}]"
修改为"yhzp": [{"url": "haha"}, {"url": "heihei"}]
在百度搜索后发现是自己的 json 写错了,应将"yhzp": "[{'url': 'haha'}, {'url': 'heihei'}]"
修改为"yhzp": [{"url": "haha"}, {"url": "heihei"}]
在百度搜索后发现是自己的 json 写错了,应将"yhzp": "[{'url': 'haha'}, {'url': 'heihei'}]"
修改为"yhzp": [{"url": "haha"}, {"url": "heihei"}]
来源地址:https://blog.csdn.net/weixin_45953673/article/details/128855078
--结束END--
本文标题: JSON parse error: Cannot deserialize value of type `java.util.ArrayList<XXX>……的解决方案
本文链接: https://lsjlt.com/news/418177.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-01
2024-04-03
2024-04-03
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0