概述
One of the common problem while parsing JSON in Java using Jackson API is that it fails when your JSON contains unknown properties i.e. your Java class doesn't have all the field corresponding to all JSON properties.
使用 Jackson API 在Java中解析JSON时的一个常见问题是,当JSON包含未知属性时,即Java类没有与所有JSON属性对应的所有字段时,解析失败。
Anyway, it was our fault that we didn't review code properly and allowed him to release his code into production without handling unknown files. The issue could have simply been avoided if he was familiar with Jackson library in a little bit more detail.
Jackson API provides two ways to ignore unknown fields, first at the class level using @JsonIgnoreProperties annotation and second at the ObjectMapper level using configure() method.
You will see both approaches in this article and learn how to use them and when to use @JsonIgnoreProperties and when to ignore unknown
最后
以上就是迷人宝贝为你收集整理的jackson 序列化忽略未知字段: How to Ignore Unknown Properties While Parsing JSON in Java的全部内容,希望文章能够帮你解决jackson 序列化忽略未知字段: How to Ignore Unknown Properties While Parsing JSON in Java所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复