At this moment I'm proceeding with Jettison 1.3.3 and CXF 2.6.0 which holds 
good with the list.

I didn't find time to hit JacksonJson with the sequence directly, until I do 
that and find a solution I will rely on Jettison.

Adding @XmlElement(nillable = true) is possible but difficult in my bit big 
schema. 

FYI - when I tried to upgrade CXF from 2.6.0 to 2.7.2 I faced an issue with 
Jaxb-impl-2.1.13.jar.  
I exclude this artifact in my pom as its conflicting with the jar's of weblogic 
11g.

So I had to back to my existing CXF 2.6.0 version.  I'll try reproducing the 
issue by upgrading to 2.7.2 when I get some time to provide you the stack trace.

Thanks
John


On Jan 25, 2013, at 4:32 PM, "Sergey Beryozkin-5 [via CXF]" 
<[email protected]> wrote:

> On 24/01/13 10:12, Sergey Beryozkin wrote:
> 
> > On 24/01/13 08:39, jbright wrote: 
> >> I see the primary issue (unmarshal json containing list) is fixed, 
> >> perhaps 
> >> its good for very small designs .. 
> >> 
> >> In case of an enterprise application 'arrayKey' is a (unwanted / 
> >> unnecessary) configuration, having lot of elements that will be of list 
> >> type. So while designing we need to keep a constant eye on the 
> >> beans.xml to 
> >> add the list elements.... the maintainability is difficult. 
> >> 
> >> Also, see the difference in what we get from JacksonJsonProvider and the 
> >> JSONProvider of Jettison. 
> >> 
> >> *JacksonJson* 
> >> 
> >> { 
> >> "errors": null, 
> >> "smeHeader": 
> >> [ 
> >> { 
> >> "smeHeaderDtls": 
> >> { 
> >> "name": "Jackson Json", 
> >> "age": 25, 
> >> "location": "India", 
> >> "doB": "1985-04-28" 
> >> } 
> >> } 
> >> ] 
> >> } 
> >> 
> >> *Jettison* 
> >> 
> >> { 
> >> "SearchMeResponse": 
> >> { 
> >> "SmeHeader": 
> >> [ 
> >> { 
> >> "SmeHeaderDtls": 
> >> { 
> >> "Name": "Jackson Json", 
> >> "Age": 25, 
> >> "Location": "India", 
> >> "DoB": "1985-04-28" 
> >> } 
> >> } 
> >> ] 
> >> } 
> >> } 
> >> 
> >> 
> >> However, I would try to use Jettison If at all I can get the 'null' 
> >> objects 
> >> also listed in the JSON response like the one in JacksonJson.. 
> > 
> > Well, Jackson is known to produce more optimal JSONs by default, kudos 
> > to the team, to be honest I think the only way to do it right is to have 
> > the introspection mechanism in place to know what exactly is coming 
> > next, a start of the array or something else; this is not possible at 
> > Jettison level - all it gets is the stream writer events when writing. 
> > 
> > That said - you can easily configure JSONProvider to drop certain 
> > elements (example, with 'dropRootElement' property and/or transform drop 
> > [1]), and in combination with the keys hints you can control the output 
> > pretty well in many cases. In this case setting "dropRootElement" will do. 
> > 
> > Regarding 'null' values: I'm not sure yet - again depends on how JAXB 
> > Marshaller reports empty collections - may be it does not even report 
> > them, if it does not then we won't be able to do it, otherwise we may be 
> > able to configure it somehow. 
> > In cases like this extending JSONProvider and registering a basic writer 
> > will work well for simple cases, for example, one can get this writer 
> > check if "errors" has been reported by the time "smeHeader" is being 
> > reported, if not - preprocess it with start/stop "errors" event, with 
> > value being 'null' - I can provide more info if you'd want to experiment
> 
> FYI, adding @XmlElement(nillable = true) and configuring the provider 
> with setWriteXsiType(false); will help with emitting even null elements, 
> the only issue is that Jettison will actually write, say, "errors":"", 
> instead of "errors":null, I think Jettison may have to be enhanced a bit 
> to optionally write null instead of "", but that will happen, if it can 
> be done in Jettison 1.3.4 
> 
> Sergey 
> 
> > 
> > Cheers, Sergey 
> > 
> > [1] 
> > http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CustomizingJAXBXMLandJSONinputandoutput
> > 
> > 
> > 
> >> 
> >> Sergey, could you pls let me know on how to get the null objects also.. 
> >> 
> >> 
> >> 
> >> -- 
> >> View this message in context: 
> >> http://cxf.547215.n5.nabble.com/JSONProvider-unable-to-unmarshal-json-containing-list-of-elements-tp5715651p5722115.html
> >> 
> >> Sent from the cxf-user mailing list archive at Nabble.com. 
> > 
> >
> 
> 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://cxf.547215.n5.nabble.com/JSONProvider-unable-to-unmarshal-json-containing-list-of-elements-tp5715651p5722252.html
> To unsubscribe from JSONProvider unable to unmarshal json containing list of 
> elements, click here.
> NAML




--
View this message in context: 
http://cxf.547215.n5.nabble.com/JSONProvider-unable-to-unmarshal-json-containing-list-of-elements-tp5715651p5722278.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to