Hi
Kyle Sampson wrote:
I have a simple service with the following method in the service endpoint
interface:
public Collection<String> getNames();
This service is exposed in CXF as a ReST service, returning JSON. It seems
to work as expected, most of the time. The collection would be represented
in JSON as, for example: ["name1","name2"]. However, if there's only one
element in the array, the brackets are missing: "name1". Thus, it looks
like just a scalar value, which confuses the consuming client.
I'm not sure if this is a CXF issue or a problem in Jettison. There does
seem to be a bug for something like this in the Jettison project: http://jira.codehaus.org/browse/JETTISON-22. However, this
seems to have
been fixed in the most recent version of Jettison, and the version included
with the CXF distribution should have the fix. Anyone else have any idea
why it's doing this? Thanks.
FYI, I'm using CXF 2.0.5.
Please try jettison-1.1-20080424.080632-3, as recommended by Brice, this issue
might've been fixed there already.
CXF currently depends on the 1.0 version of Jettison....
This issue was recently discussed in the Jersey user group. You can write a custom JAXB context resolver to fix this issue. Please
look at [1] for details. But, I am not sure how to implement custom JAXB context resolver in CXF JAX-RS implementation.
Arul, this is part of the 0.7 spec and Kyle is not using JAX-RS at the moment. Hopefully though this specific issue will be fixed at
the Jettison level.
Cheers, Sergey
[1] http://blogs.sun.com/japod/entry/missing_brackets_at_json_one
Cheers,
Arul
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland