Ignoring null values ​​when marshaling an object in JSON using RESTeasy and Jettison

When RESTeasy marshals a POJO in XML, it by default skips null values: See. The Jaxb marker always writes xsi: nil (even if @XmlElement (required = false, nillable = true)) .

However, when marshaling to JSON, null properties are included. Is there a way to make the JSON output match the XML output file?

+4
source share
1 answer

To ensure that null values ​​are not included in JSON, the following annotation can be used in a getter or public variable declaration: @JsonSerialize (include = Inclusion.NON_NULL)

+1
source

Source: https://habr.com/ru/post/1379078/


All Articles