Hi Jalpesh,
Does the following help:
https://jaxb.dev.java.net/tutorial/section_2_2_12_8-No-Value.html#No
%20Value
?
Paul.
On May 13, 2009, at 1:41 AM, Jalpesh Patadia wrote:
> Hello everyone,
>
> I had a quick question on output formatting. Out of the box jersey
> supports XML and Jason, which is great for my application. However
> when I was using it, I noticed that output ignores fields with null
> values. So if you have an object
>
> @XMLRootElement
> Class Foo {
> Integer num;
> Date date;
> ….
> }
>
> When this has been marshalled into the XML file if the date field is
> null, my output does not have that element in it. What I want to do
> is include all the fields in the output; and if they are null,
> replace them with - say a blank. So for “application/xml” the
> output should be :
>
> <foo>
> <num>123</num>
> <date></date>
> </foo>
>
>
> I think Jersey uses JAXB internally to do the marshalling, and I
> wasn’t able to find anything in the JAXB documentation on how to do
> that, so I’m a bit concerned if something like this is even possible.
>
>
> Thanks,
>
>
> Jalpesh.
>
> PRIVILEGED AND CONFIDENTIAL
> This transmission may contain privileged, proprietary or
> confidential information. If you are not the intended recipient, you
> are instructed not to review this transmission. If you are not the
> intended recipient, please notify the sender that you received this
> message and delete this transmission from your system.