users@jersey.java.net

Re: [Jersey] Output formatting.

From: Bruno Vernay <brunovern.a_at_gmail.com>
Date: Thu, 14 May 2009 17:29:34 +0200

Also I found the @XmlJavaTypeAdapter(MyDateAdapter.class) to be very
useful, even for JSON !

It would be great to have a links in the Jersey User guide
[https://jersey.dev.java.net/documentation/1.1.0-ea/user-guide.html]
to resources like:
- "Generate an XML Document from an Object Model with JAXB 2 /
Customize the XML Document"
[http://www.devx.com/Java/Article/34069/0/page/3]
- "JAXB Tutorial / 6.2.9 Type Adapters: XmlJavaTypeAdapter"
[https://jaxb.dev.java.net/tutorial/section_6_2_9-Type-Adapters-XmlJavaTypeAdapter.html#Type%20Adapters:%20XmlJavaTypeAdapter]

Thanks
Bruno


On Wed, May 13, 2009 at 6:13 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> 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.
>
>



-- 
Bruno VERNAY