Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJECT`)
时间: 2023-09-24 08:04:20 浏览: 400
引用\[1\]:错误信息:org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.lang.Integer from Object value (token JsonToken.START_OBJECT); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.Integer from Object value (token JsonToken.START_OBJECT) 出错原因:测试时 workStatus为空,导致报错。 解决方法:去掉空值即可。。 引用\[2\]:"JSONparseerror:Cannotdeserializevalueoftype`java.util.ArrayList<xxx>`fromObjectvalue(token`JsonToken.START_OBJECT`);nestedexceptioniscom.fasterxml.jackson.databind.exc.MismatchedInputException:Cannotdeserializevalueoftype`java.util.ArrayList<xxx>`fromObjectvalue(token`JsonToken.START_OBJECT`)\nat\[Source:(org.springframework.util.StreamUtils$NonClosingInputStream);line:3,column:22\](throughreferencechain:cn.com.sinosoft.entity.dto.EnclosureUploadDTO\[\"enclosureList\"\])", 。 引用\[3\]:乍一看没啥问题啊,一执行的时候就报告错误 { "code": 500, "msg": "JSON parse error: Cannot deserialize value of type `java.util.ArrayList<cn.com.sinosoft.entity.Enclosure>` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList<cn.com.sinosoft.entity.Enclosure>` from Object value (token `JsonToken.START_OBJECT`)\n at \[Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 3, column: 22\] (through reference chain: cn.com.sinosoft.entity.dto.EnclosureUploadDTO\[\"enclosureList\"\])", "data": null } 。 问题:Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJECT`)
回答: 这个错误是由于在JSON解析过程中,尝试将一个对象类型的值转换为Integer类型时引发的。具体来说,错误信息中的"Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJECT`)"表示在解析过程中遇到了一个对象类型的值,而期望的是一个Integer类型的值。这可能是因为在JSON中,该字段的值被错误地设置为了一个对象,而不是一个整数。要解决这个问题,需要检查JSON数据中对应的字段,确保它的值是一个合法的整数,而不是一个对象。
#### 引用[.reference_title]
- *1* [Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJEC](https://blog.csdn.net/weixin_44508895/article/details/130195442)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [“JSON parse error: Cannot deserialize value of type `java.util.ArrayList<XXX>` from Object value ...](https://blog.csdn.net/xiaoheihai666/article/details/127817980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文