【报错解决】springmvc控制台报错JSON parse error

报错信息:
JSON parse error: Unrecognized token ‘username’: was expecting (‘true’, ‘false’ or ‘null’); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘username’: was expecting (‘true’, ‘false’ or ‘null’) at [Source: (PushbackInputStream); line: 1, column: 10]]

报错原因:
这是由于请求的json数据的格式有问题
原数据格式:{“username”:“张三”,“age”:20,“address”:“深圳”}

解决方法:
使用 JSON.stringify(data)这个函数,该函数会将动态的Object转成静态json String。
修改后格式:
JSON.stringify({“username”:“张三”,“age”:20,“address”:“深圳”})

发布了17 篇原创文章 · 获赞 1 · 访问量 630

猜你喜欢

转载自blog.csdn.net/weixin_43316702/article/details/105041749