I have a POJO and Im trying to exclude null fields by using the Include.NOT_EMPTY
annotation in the following manner.
Updated with Complete code
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Items {
/**
*
*/
@JsonProperty("items")
private List<Item> items = new ArrayList<Item>();
private Map<String, Object> additionalProperties =
new HashMap<String, Object>();
/**
*
* @return
* The items
*/
@JsonProperty("items")
public List<item> getItems() {
return items;
}
/**
*
* @param items
* The items
*/
@JsonProperty("items")
public void setitems(List<Item> items) {
this.items = items;
}
@JsonAnyGetter
@JsonUnwrapped
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
However,when I print out the JSON, I get a response in the following manner.
{ "items": [
{...}],
"additionalProperties": { } // I expect this to be removed.
}
Any idea what Im doing wrong here? I'm using Jackson-core 2.1.1 if that matters.