I have a strange issue marshalling an empty object collection to json using jersey with the jaxb based json support. My object looks like
...
@XmlWrapper(name = "stuff") @XmlElement(name = "s")
private List<Foo> foos;
...
Marshaling this to json produces the expected results
... stuff: [{ "s": ... }, { "s": ... }] ...
except when the list is empty. I would expect to see
... stuff: [] ...
but I see
... stuff: [null] ...
instead. Any idea what's wrong? The problem seems to be related to the @XmlElementWrapper
annotation, removing it I don't get the the stuff
property in the output at all.