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 10:13:45 +0100

On Fri, Dec 11, 2009 at 07:10:12AM +0100, Felipe Gaścho wrote:
> do we have a sample in Jersey examples folder ?

http://download.java.net/maven/2/com/sun/jersey/samples/jacksonjsonprovider/jacksonjsonprovider/1.1.5-ea-SNAPSHOT/jacksonjsonprovider-1.1.5-ea-SNAPSHOT-project.zip

still due to write a readme doc, though

~Jakub

>
> On Fri, Dec 11, 2009 at 12:32 AM, Tatu Saloranta <tsaloranta_at_gmail.com> 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).
> > 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
> >
> >
>
>
>
> --
> ------------------------------------------
> Felipe Gaścho
> 10+ Java Programmer
> CEJUG Senior Advisor
>
> ---------------------------------------------------------------------
> 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