users@jersey.java.net

[Jersey] Re: return Array of Primitives

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 22 Feb 2011 10:42:29 -0800

On Tue, Feb 22, 2011 at 8:41 AM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
...
> yes, thats expected too. If you really want JSON output, you should do
> something like this:
>
>    @GET
>    @Path("/a")
>    @Produces("application/json")
>    public JSONArray getMessages() {
>        List<String> l = new ArrayList<String>();
>        l.add("a");
>        l.add("b");
>        l.add("c");
>        return new JSONArray(l);

I think easier way would be to use plain POJO mapper, since Jackson
can serialize both List<String> and String[] just fine.

-+ Tatu +-