I believe this is a "bug"/"restriction" in jettison[1] which is the library we 
use for producing json.    I know with 1.1, they are adding some mapping 
things to provides ways to specify how things are written out.   No idea when 
1.1 will be released though.   

Dan

[1] http://jettison.codehaus.org


On Thursday 20 November 2008 7:49:18 pm Maleldil wrote:
> 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 ).
> 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.



-- 
Daniel Kulp
[EMAIL PROTECTED]
http://dankulp.com/blog

Reply via email to