users@jersey.java.net

Re: [Jersey] Question on JAXB JSON Marshalling

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 06 Feb 2009 09:47:32 +0100

On Feb 6, 2009, at 1:19 AM, Jakub Podlesak wrote:

>
> Hi Farrukh,
>
> We wanted to produce the JSON documents to be as simple
> as possible for clients

I would add specifically JavaScript clients (even though the JSON
format may be more appealing as a data-format than say XML).

> to consume.

Right, that is the main point of JSON, which is why i think more
literal mappings like BadgerFish miss the point, one might as well
use XML and E4X.

The problem that is really hard to juggle is that different users
have different expectations on how they want the XML infoset produced
by JAXB to be mapped to JSON. Which is why we have tried to offer
different notations to meet that need.

What i think we need is some good clear documentation on the
"NATURAL" convention we have just introduced so that users can decide
whether that is appropriate for them or not. And we should avoid
mentioning XSD in such documentation :-)

Paul.

> That is why, by default, the root element gets stripped off.
>
> If you use MAPPED notation, you can however switch
> the root element marshalling on.
>
> I do not know what configuration method you are using,
> but look for "root unwrapping" configuration property.
>
> HTH,
>
> ~Jakub
>
>
> On Thu, Feb 05, 2009 at 12:50:05PM -0500, Farrukh Najmi wrote:
>>
>> I have a JAXB object as my response which in normal XML format
>> looks like:
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <RegistryObjectList ...>
>> <RegistryObject ...>
>> ....
>> </RegistryObject>
>> </RegistryObjectList>
>>
>> When it is marshalled to JSON I get:
>>
>> {
>> "RegistryObject":{
>> ...
>> }
>> }
>>
>>
>> Question is why is it not like:
>>
>> {
>> "RegistryObjectList":{
>> "RegistryObject":{
>> }
>> }
>> }
>>
>> Why is the root element not being marshalled?
>>
>> --
>> Regards,
>> Farrukh
>>
>> Web: http://www.wellfleetsoftware.com
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>