我是靠谱客的博主 迷人宝贝,最近开发中收集的这篇文章主要介绍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 序列化忽略未知字段: How to Ignore Unknown Properties While Parsing JSON in Java所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部