users@jersey.java.net

Re: [Jersey] XML Schema, JSON arrays and java List<String>

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 4 Aug 2009 13:47:11 -0700

On Tue, Aug 4, 2009 at 3:28 AM, Martin Probst<mail_at_martin-probst.com> wrote:
> Hi,
>
>> {"message-keys":{"msg-key":["input.incorrect","foo","bar"]}}
>>
>> Any tricks I am missing to remove the need for the msg-key property?
>
> I think this came up several times, and the consensus is that you're
> basically out of luck with the POJO->XML->JSON route to get something
> nice (in several places). If you want to produce "natural" JSON
> especially for things like maps and lists. You could use Jackson which
> makes it much easier to get nice JSON, though you'll have twice the
> annotations.

Even better, with 1.1 and 1.2 releases, Jackson also offers support
for (relevant subset of) JAXB annotations (see
[http://wiki.fasterxml.com/JacksonJAXBAnnotations]), so it may be
possible to just use one set. Quite often you don't even need
annotations for Jackson, unless you need to change naming convention.
Anyway: to use 1.1 (or just released 1.2), one needs to update jackson
jars Jersey uses. This should be easy as Jersey by default only uses
the "core" jar I think.

-+ Tatu +-

ps. I need to add this to jackson FAQ and docs, but a simple way to
register jax-rs provider is shown, for example, at the end of this
post: [http://www.cowtowncoder.com/blog/archives/2009/03/entry_229.html]