我是靠谱客的博主 迷人宝贝,这篇文章主要介绍jackson 序列化忽略未知字段: How to Ignore Unknown Properties While Parsing JSON in Java,现在分享给大家,希望可以做个参考。

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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部