The new Jackson-API provides us with convenient XML-Binding (just like JAXB for example), but i cant find any way to make Jackson serialize the typical "xsi:nil"-Attribute that is defacto standard to represent NULL-Values in XML? Please correct me if i see this wrong ;-)
In JAXB this can be done easily by annotating a java-variable with: @XMLElement(nillable=true)
see also: http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html
Can Jackson do this ?
for Jackson-XML see: https://github.com/FasterXML/jackson-dataformat-xml
This does not answer the question but provides a workaround (very hacky)!
I managed to write some custom serializers/deserializers for jackson (until jackson officially supports xsi:nil), that allow the following:
With this code one can provide interoperability to other xml-binding libraries (JAXB..) that can only work with xsi:nil for null-values.
Class Item:
Class Main:
Class MyNullSerializer:
Class MyNullDeserializer: