Hi,

Yeah, if it's only a single root element which is dealt with and this
property is set then it would be easy for JSONProvider to wrap again, but if
it is not set then it can try to deduce the node name automatically given
that in its readFrom() method it has an access to the parent bean
instance... Actually, I haven't thought about injecting the node name
property but for simple cases it will make it easy and fast indeed for
JSONProvider.

So if it sounds like it should work then I will do it in time for the 2.2.3
release. In meantime, you might want to create a custom provider by slightly
modifying the existing one (yet again :-), using your idea of injecting a
node name property.

thanks, Sergey


Paul Wilton wrote:
> 
> Yep - 
> that sounds like something that could work :
> just to be clear, you are suggesting simply adding a setter on
> JSONProvider 
> for example  setWrappedNodeElement(String nodeName) 
> that would decorate the InputStream with the nodeName so the JAXB
> unmarshalling would go ahead as normal, and unmarshal the decorated JSON
> into the bean (specified by the node name)
> 
> Paul
> 
> 
> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]] 
> Sent: 06 July 2009 16:57
> To: [email protected]
> Subject: Re: JSON in CXF - root element dropped
> 
> 
> Hi Paul
> 
> Yes, I remember we were talking with Tony about it. I think Tony
> expressed
> some interest in enhancing the CXF JSON provider but the idea was to use
> JSON annotations so that users could choose not to depend on the
> JAXB-driven
> serialization. People are often referring to Jackson but I don't know if
> it's capable of handling JAXB beans fully. Dejan has released Jettison
> 1.1
> and fixed some blockers so, as far as JSON & JAXB is concerned we feel
> we're
> kind of ok with Jettison being the default JAXB provider for now.
> Perhaps we
> can see some more Jettison micro releases going forward. In fact, I've
> talked to him today about what appears to be a very similar issue :
> 
> http://www.nabble.com/Supprot-for-wrapped-unwrapped-styles-in-Mapped-con
> vention-for-JSON-td24319534.html
> 
> It's something that a JSON library probably can't fix on its own as it
> does
> not know what parent object a given JSON sequence belongs to.
> 
> Does the idea of replacing an InputStream with a new one which would
> decorate {the unwrapped sequence} with "{jaxb-name-of-parent-bean:" &
> "}"
> sound reasonable ? This can be done in the JSONProvider quite easily...
> 
> cheers, Sergey
> 
> 
> Paul Wilton wrote:
>> 
>> Hi Sergey,
>> 
>> Recall this conversation (back in Feb 2009), about consuming JSON
> where
>> a list of objects has had the root element dropped (in XML response
> the
>> root element would remain) :
>> 
>>
> http://mail-archives.apache.org/mod_mbox/cxf-dev/200902.mbox/%3C019d01c9
>> [email protected]%3e
>> 
>> I am also in position of trying to consume a Web service with no root
>> element in the JSON response, and the standard JSON provider can't
>> handle it because of lack of the root element.
>> 
>> You said :
>> "I'd happy to consider replacing the existing one (JSONProvider) with
> a
>> better quality one if it were JAXB
>> driven as a number of users depend on it 
>> being JAXB aware, such that we can also preserve the existing features
>> like the ability to
>> schema-validate, which should not be a 
>> problem if it were JAXB-aware."
>> 
>> Did this get taken any further, and if not, is something that could be
>> addressed?
>> 
>> Thanks
>> Paul 
>> This e-mail (and any attachments) is confidential and may contain
> personal
>> views which are not the views of the BBC unless specifically stated.
> If
>> you have received it in error, please delete it from your system. Do
> not
>> use, copy or disclose the information in any way nor act in reliance
> on it
>> and notify the sender immediately.
>>  
>> Please note that the BBC monitors e-mails sent or received. Further
>> communication will signify your consent to this
>> 
>> This e-mail has been sent by one of the following wholly-owned
>> subsidiaries of the BBC:
>>  
>> BBC Worldwide Limited, Registration Number: 1420028 England,
> Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> BBC World News Limited, Registration Number: 04514407 England,
> Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> BBC World Distribution Limited, Registration Number: 04514408,
> Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Re%3A-JSON-in-CXF---root-element-dropped-tp2435755
> 1p24358143.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Re%3A-JSON-in-CXF---root-element-dropped-tp24357551p24358527.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to