Jackson: JsonInclude how to add Multiple JsonInclude annotation type

对着背影说爱祢 提交于 2020-08-19 06:02:21

问题


How can I tell a class to include only NON_EMPTY and NON_NULL values only, Using

@JsonInclude(Include.NON_NULL)
@JsonInclude(Include.NON_EMPTY)
public class foo{
    String a;
}

is throwing error of duplicate annotation.


回答1:


"Null is always considered empty" - Jackson's site

So the NON_EMPTY rule covers both cases..



来源:https://stackoverflow.com/questions/23631511/jackson-jsoninclude-how-to-add-multiple-jsoninclude-annotation-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!