Jersey appears to have a set of predetermined default values for JSON nulls while unmarshalling via JAXB: String => “”, Integer => 0, … is there anyway to easily control these values either with configuration or annotations?
Using Jersey’s POJO mapping I get what I want, which is to map JSON null to Java null, but for other reasons we really need to use JAXB.
It seems like this should be simple however I’m drawing a blank.
Thanks.
Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
The JAXB (JSR-222) specification does not cover JSON-binding so what you are experiencing is Jersey code interacting with the JAXB reference implementation producing some odd results wrt null handling. EclipseLink MOXy is a JAXB compliant implementation that also offers JSON binding that has more natural null handling.
If this was marshalled to JSON the result would be the following. Null values are not marshalled to JSON unless they are annotated with
@XmlElement(nillable=true):For More Information
Jersey Integration