users@jersey.java.net

Single element List in JSON

From: Comerford, Sean <Sean.Comerford_at_espn3.com>
Date: Tue, 12 Jan 2010 21:12:06 +0000

So wešre running into an (apparently known issue) where Jersey endpoints
that return a List are NOT returning a JSON array when the List has only 1
item in it.

One potential fix is described at
http://blogs.sun.com/enterprisetechtips/entry/configuring_json_for_restful_w
eb

But Išm hoping (probably falsely) that maybe therešs a better way to solve
this issue.

Am I misreading it or do you really need to specify the name of every
element you intended to use in a JSON array to the call
props.put(JSONJAXBContext.JSON_ARRAYS, new
HashSet<String>(1){{add("jobs");}?

That blog post is well over a year old so just wondering if maybe therešs an
easier / more automagic way than overriding the default JAXB properties for
each element name ­ that seems pretty brutal.

-- 
Sean Comerford, Software Engineer
ESPN.com Site Architecture Group
Office: 860.766.6454    Cell: 860.329.5842