我有这样的 pojo:
@JsonIgnoreProperties(ignoreUnknown = true)
public class SNAPIResponse {
public String status;
public String message;
public int errorCode;
public ConsumerProfile consumerProfile;
@JsonIgnoreProperties(ignoreUnknown = true)
public static class ConsumerProfile {
public String accountId;
}
}
我的泽西岛客户工作得很好,即使ConsumerProfile
响应包含许多额外字段。
然后我添加一行:
client.register(JacksonFeature.class);
我的泽西岛客户端设置。之后,忽略不再起作用:
Unrecognized field "authService" (Class com.xyz..SNAPIResponse$ConsumerProfile), not marked as ignorable
Why?
我偶然发现这篇文章,它帮助我让 JsonIgnoreProperties 再次工作:http://jersey.576304.n2.nabble.com/Beware-of-JacksonFeature-in-Jersey-td7581633.html http://jersey.576304.n2.nabble.com/Beware-of-JacksonFeature-in-Jersey-td7581633.html
我没有进行足够的研究,无法 100% 确定问题的根本原因,但注册 JacksonFeature.class 似乎会引入为此所需的过时版本的库。
按照该链接中的建议进行操作对我有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)