users@jersey.java.net

Re: [Jersey] Rid off the _at_at symbol on JSON responses?

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Fri, 11 Dec 2009 11:57:04 +0100

On Fri, Dec 11, 2009 at 11:45:37AM +0100, Paul Sandoz wrote:
>
> On Dec 11, 2009, at 12:32 AM, Tatu Saloranta wrote:
>
> >2009/12/10 Felipe Gaúcho <fgaucho_at_gmail.com>:
> >>thanks Brown,
> >>
> >>but if I need to add a new framework just to remove the @ then I
> >>prefer to convert the attributes in elements.. then it is
> >>solved........... no extra code needed.............
> >
> >No new framework. And library (jar) in question is already bundled by
> >Jersey (although not 100% sure if jackson-jax-rs jar is).
>
> IIRC jackson-jax-rs is not currently included, Jakub can confirm. But
> jackson is (and distributed with GF v3!).

Confirmed.

~Jakub

>
> Paul.
>
>
> >Jackson is used for parsing and writing JSON by Jersey. Just need a
> >line or two of code to register provider (for
> >MessageBodyReader/Writer):
> >
> >
> >
> >> I know there are tons of JSON & XML parsers out there.. but I am
> >>trying to reduce the amount of code to deploy and configure..........
> >>so I am still looking for the Jersey roots :)
> >
> >Right, and that's the point: Jackson comes with JAX-RS content
> >provider, out of the box.
> >No need to do anything super special. :-)
> >I like Jersey (and JAX-RS) in general -- like others have said,
> >default of using badgerfish/mapping notation is a historical artifact.
> >There are other ways too, like Jakub mentioned natural notation. Just
> >because something is the default should not mean users don't use it.
> >:-)
> >(that is, don't fear changing defaults)
> >
> >-+ Tatu +-
> >
> >ps. For completeness sake, here's the entry from Jackson FAQ:
> >
> >---
> >In addition to adding jackson-jaxrs jar (and jackson core and mapper
> >jars it depends on, if not bundled by the JAX-RS implementation), you
> >will also need to register provider. There are 2 ways to do this:
> >
> > * Add root provider with JAX-RS registration mechanism; for
> >example, by returning provider class/instance from Rest Application
> >class.
> > * Add 'META-INF/services/javax.ws.rs.ext.MessageBodyReader' file
> >with one entry, provider class name
> >(org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvide) (and similarly for
> >MessageBodyWriter) to a jar that gets loaded by JAX-RS implementation
> >(this can be done by post-processing jackson-jaxrs jar, for example).
> >
> >Here's one implementation of second approach:
> >
> >import java.util.*;
> >
> >public final class RestApplication extends
> >javax.ws.rs.core.Application
> >{
> > public Set<Object> getSingletons() {
> > HashSet<Object> singletons = new HashSet<Object>();
> > singletons.add(new
> >org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider());
> > return singletons;
> > }
> >}
> >---
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
http://blogs.sun.com/japod