java - Java - 无法从 START_OBJECT 令牌中反序列化 java.lang.Integer 的实例?
问题描述
当我尝试将POST
一个人反对 3rd 方 API 时,我的应用程序中出现以下错误:
Can not deserialize instance of java.lang.Integer out of START_OBJECT token
at [Source:
(through reference chain: Person["postcode"]
我认为问题在于我将邮政编码作为整数,而在 API 合同中它是一个 json 数组。
如何Json array
在我的 Java POJO 中将 a 表示为一个字段?
POJO:
public class Person {
@JsonProperty
private Integer id;
@JsonProperty("postcode")
private Integer postcode;
// other fields...
}
即在来自成功 POST 的 JSON 响应中,该"postcode"
字段为:
"postcode": [],
解决方案
推荐阅读
- python - Python打印与输入重叠
- kubernetes - 为什么这么多流行的 Helm 图表的安全等级很低?有关系吗?
- python - Odoo13 - PDF 打印的差异 - 丢失页码
- .net-core - 无法将 github 操作成功添加到 azure 应用服务
- javascript - 如何使用 selectsize.js 制作分隔符?
- java - 使用 Spring Boot 在每个 Cucumber 场景后回滚事务
- python - 为什么这个函数返回不同的值?
- python - 将 txt 文件传递到 pandas 数据帧
- postgresql - 无法从 Tableau srv 连接到 PostgreSQL srv
- php - Symfony 4.4 Auth0 如何从应用程序中完全注销用户