Hi
I am using JAX-RS and CXF 2.1.3. I have value objects that model my JSON
schemas and usually everything works great. The problem is that I when a
list of objects only contains one item then the resulting JSON is not
serialized as an array, but as an object. Example:
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.
I've found a few mentions of this issue in CXF but with no solutions.
Jersey has the same issue but I found a blog article that explains how to
fix it in their framework (
http://blogs.sun.com/japod/entry/missing_brackets_at_json_one see here ).
ContextResolvers are supported by CXF JAXRS and its JSON provider will check an injected context resolver if any, so it should work
with a custom context resolver as recommended by Jakub. In CXf it can be registered as a provider, using Spring config for ex
Let me know please if it works for you
Cheers, Sergey
Is there anything that can be done about this in CXF though? This is really
a showstopper for our project and needs to be resolved, and seems like a
major issue in general.
Any help would be appreciated.
--
View this message in context:
http://www.nabble.com/Lists-containing-one-object-are-not-serialized-as-JSON-arrays-tp20613099p20613099.html
Sent from the cxf-user mailing list archive at Nabble.com.