Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jackson: JsonInclude how to add Multiple JsonInclude annotation type

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.

like image 683
Dheerendra Avatar asked May 13 '14 12:05

Dheerendra


Video Answer


1 Answers

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

So the NON_EMPTY rule covers both cases..

like image 176
larryboymi Avatar answered Oct 11 '22 17:10

larryboymi