I ran into this issue as well. I posted a test to the issue below to reproduce. Since this is unlikely to be fixed/released soon, I'm started looking at Jackson as a JSON Provider to solve my problem. I'm able to plug it into CXF by defining a "jacksonProvider" bean and referencing it in <jaxrs:providers>.
<bean id="jacksonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> However, the default JSON returned is very generic and doesn't contain type information like the JSON Provider from Jettison. Does anyone know the best way to solve this? The following page shows how to make Jackson JAXB-aware, but I'm unsure of how to configure this in CXF's Spring configuration. https://docs.codehaus.org/display/JACKSON/Jackson+JAXB+Support The only solution I can think of is to use a Bean PostProcessor to find the provider and change the configuration. Thanks for any assistance. Matt Sergey Beryozkin wrote: > > Hi > > Looks like it is this one : > > http://jira.codehaus.org/browse/JETTISON-57 > > hope we can get a future Jettison 1.1.2 fixing this too > > One possible workaround (if it's really critical and it has to > JAXB-driven) is to use an XSLTJaxbProvider customized to invoke a specific > template when application/json is encountered. This template would just > produce a text JSON stream as needed, based on the input XML... > > cheers, Sergey > > > dkulp wrote: >> >> >> Thanks for the update. Definitely log an issue there: >> http://jira.codehaus.org/browse/JETTISON >> >> >> Dan >> >> >> On Wed August 12 2009 1:44:45 pm Stephen Lynn wrote: >>> I've been digging some more and it looks like the problem is in the >>> Jettison code base. Line 285 of the >>> org.codehaus.jettison.mapped.MappedXMLStreamWriter class is hardcoded to >>> check check for a stack bigger than three which means that anytime you >>> have >>> a parent class that has a property of the same name as one of it's >>> children >>> we get a clash. This code really needs to track a depth as well so it >>> can >>> keep the two namespaces seperate when it does the serialization. I >>> guess >>> this is more of a Jettison issue that CXF issue. I'll post something >>> over >>> there. >>> >>> Stephen >>> >>> On Wed, Aug 12, 2009 at 9:40 AM, Stephen Lynn <[email protected]> >>> wrote: >>> > I'm trying to serialize an object tree that looks something like this: >>> > >>> > - owners >>> > - date >>> > - collections (list of collection objects) >>> > - filter >>> > - videos (list of video objects) >>> > - filter >>> > >>> > So the tree has a list of "Collection" objects and each collection has >>> a >>> > list of "Video" objects. Both Collection and Video objects contain a >>> > Filter object which is what causes the problem in the JSON >>> serialization. >>> > If I rename the filter variable in Video to "videoFilter" (or >>> anything >>> > different than "filter") then serialization works fine but if both >>> > objects have a child with the same name then things get all mixed up. >>> > >>> > By mixed up I mean I get a valid JSON object back but the tree is all >>> > rearranged so that pieces a Collection object appear at the root of >>> the >>> > tree and nothing is in the proper place. >>> > >>> > Has anyone else seen this problem? Are there any fixes/workarounds >>> other >>> > than renaming properties? >>> > >>> > Thanks, >>> > >>> > Stephen >> >> -- >> Daniel Kulp >> [email protected] >> http://www.dankulp.com/blog >> >> > > -- View this message in context: http://www.nabble.com/json-serialization-confused-tp24939307p25258465.html Sent from the cxf-user mailing list archive at Nabble.com.
