users@jersey.java.net

Re: [Jersey] Output formatting.

From: Bruno Vernay <brunovern.a_at_gmail.com>
Date: Mon, 18 May 2009 11:33:13 +0200

Hi,

I still haven't log an RFE, for the doc, but I have another problem:

We use a JSON format that is mostly "Natural" ... but with
rootWrapping (or rootUnWrapping set to false). I didn't find a way to
do it.

- I searched in JAXB for a way to enclose my RootElement in another
"root": didn't find anything.

- I tried the JSONConfiguration.builder way. The only solution I see
is to use the MAPPED_JETTISON and declare all arrays to follow the
"natural" convention. This would be very impractical. (I have a lots
of them and I would have to keep them in sync).

Could it be possible to have the rootUnWrapping option in the
"Natural" builder in a soon-to-be-released version ?? Or did I miss
something ?

Thanks
Bruno


On Fri, May 15, 2009 at 10:57 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
> On May 14, 2009, at 5:29 PM, Bruno Vernay wrote:
>
>> 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]
>>
>
> We need to a chapter on JAXB usage. Can you log an issue so we do not forget
> about the above?
>
> Thanks,
> Paul.
>
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Bruno VERNAY