users@jersey.java.net

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

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Wed, 05 Aug 2009 12:39:58 +0200

On Tue, Aug 04, 2009 at 01:47:11PM -0700, Tatu Saloranta wrote:
> 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

I have upgraded jackson dependency at the 1.1.2-ea-SNAPSHOT Jersey version,
so that the 1.1.1 version of jackson is used, and at least for this
(jackson) version no conflict happens and the update should not be needed.
You only need to add the 1.1.1 version of jackson-jaxrs dependency.

~Jakub


> 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]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>