Java Jackson:JsonInclude 如何添加多个 JsonInclude 注释类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23631511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 00:25:30 来源:igfitidea点击:
Hymanson: JsonInclude how to add Multiple JsonInclude annotation type
提问by Dheerendra
How can I tell a class to include only NON_EMPTY and NON_NULL values only, Using
如何告诉一个类只包含 NON_EMPTY 和 NON_NULL 值,使用
@JsonInclude(Include.NON_NULL)
@JsonInclude(Include.NON_EMPTY)
public class foo{
String a;
}
is throwing error of duplicate annotation.
正在抛出重复注释的错误。
采纳答案by larryboymi
"Null is always considered empty" - Hymanson's site
“Null 总是被认为是空的” ——Hymanson 的网站
So the NON_EMPTY rule covers both cases..
所以 NON_EMPTY 规则涵盖了这两种情况。