0


前端以Json格式传递列表时的书写格式错误及解决方案

JSON parse error: Cannot deserialize value of type java.util.ArrayList from Object value (token JsonToken.START_OBJECT); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.util.ArrayList from Object value (token JsonToken.START_OBJECT) at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 1]] 前端以Json格式传递列表时的书写格式错误及解决方案

报错

*JSON parse error: Cannot deserialize value of type

java.util.ArrayList<com.tzy.entity.ComponentOilProperties>

from Object value (token

JsonToken.START_OBJECT

); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type

java.util.ArrayList<com.tzy.entity.ComponentOilProperties>

from Object value (token

JsonToken.START_OBJECT

) at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 1]]*

解决方案

报错的写法

{"setSettings":[{"name":"chongZheng","xinwan":100,"liu":0,"ben":0.6,"xiting":0,"midu":0.8},{"name":"mtbe","xinwan":116.66,"ben":3,"liu":0,"xiting":0,"midu":0.73},{"name":"feiFang","xinwan":74.34,"liu":0,"ben":0.8,"xiting":7,"midu":0.67}]}

正确写法

[{"name":"chongZheng","xinwan":100,"liu":0,"ben":0.6,"xiting":0,"midu":0.8},{"name":"mtbe","xinwan":116.66,"ben":3,"liu":0,"xiting":0,"midu":0.73},{"name":"feiFang","xinwan":74.34,"liu":0,"ben":0.8,"xiting":7,"midu":0.67}]

不需要写后端接收List的名称

标签: json java 开发语言

本文转载自: https://blog.csdn.net/a928108554/article/details/126586783
版权归原作者 John_Tao 所有, 如有侵权,请联系我们删除。

“前端以Json格式传递列表时的书写格式错误及解决方案”的评论:

还没有评论