Hi, thanks for posting a link
Can you please explain me a bit more what you do (I know you have it's all
working with Jersey) -
but I'd to try few things with Jettison
Here's your original email :
I have a list called "tags" that contains TagVO objects. A TagVO simply contains 2 string fields, called "name" and "group".
If I have two or more objects in that list then it is serialized as follows:
{tags:[{name: "tag1", group: "group1"},{name: "tag2", group: "group2"}]}
So far so good. However, if there is only one item, I will get the following:
{tags:{name: "tag1", group: "group1"}}
Which is obviously not correct.
S.B. : should it be
{tags:[{name: "tag1", group: "group1"}]}
?
Is there any chance you can post a very simple code sample showing how this list of TavVO is used or at least how do TagList and
TagVO look like (like what JAXB annotations they have) ?
Many thanks
Sergey
Sure thing. http://jira.codehaus.org/browse/JETTISON-22 Here is the link.
I mistakenly thought that this was related to
http://jira.codehaus.org/browse/JETTISON-46 this bug report which is why I
thought the latest version of Jettison would fix it, but the actual bug that
relates to this was supposedly fixed in version 1.0 of Jettison.
Sergey Beryozkin-3 wrote:
Ok, no worries.
Can you give me a favour and send a link to a Jettison JIRA which claims
to have resolved this bug ?
Thanks, Sergey
The problem is that, upon further inspection, the JSONJAXBContext
parameters
that are specified for the Jersey ContextResolver are only for their own
Mapped implementation of the JSON provider that doesn't use Jettison, and
it
doesn't look like there is any way to pass Jettison any settings that
tell
it what to do. So for now my only option is to migrate my application to
Jersey (which I have done and is working correctly).
Thank you for all your help.
Sergey Beryozkin-2 wrote:
Hi
I missed it was a Jersey specific JSONJAXBContext...
If we knew what JSON/Jettison property passed as a JAXBContext property
would help jettison to make the right decision (similar to the one used
in the Jakob's blog entry) then I guess it would still work pretty much
the same way as suggested there - but I'm not sure if such property
exists for Jettison.
You can register a custom resolver like this :
<jaxrs:providers>
<ref bean="jsonProvider"/>
<bean class="MyContextProvider"/>
</jaxrs:providers>
Supposedly this bug is fixed in the latest trunk of jettison, which I
linked
to my project, but it still does not work correctly in CXF.
May be debugging can help, if it's feasible and see if it's really been
fixed and if it's really the latest jettison library you expect is being
picked up as opposed to the buggy one (unlikely - but it might happen -
it happens to me anyway now and then :-))
Cheers, Sergey
--
View this message in context:
http://www.nabble.com/Lists-containing-one-object-are-not-serialized-as-JSON-arrays-tp20613099p20632671.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
View this message in context:
http://www.nabble.com/Lists-containing-one-object-are-not-serialized-as-JSON-arrays-tp20613099p20666834.html
Sent from the cxf-user mailing list archive at Nabble.com.