users@jersey.java.net

Re: [Jersey] JSON and arrays of length one

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Fri, 06 Nov 2009 18:27:34 +0100

On Fri, Nov 06, 2009 at 10:55:15AM -0600, FSauer_at_dsthealthsolutions.com wrote:
> Thanks, that helps, but is there a way to do this as a default, without

Great.

> having to register my resource classes?
> Is there a servlet param I can set to make 'natural' the default JSON
> builder for all classes?

Not yet, but it seems we definitely need it.

~Jakub

>
> Thanks,
>
> Frank
>
>
>
> Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
> Sent by: Jakub.Podlesak_at_Sun.COM
> 11/06/2009 10:39 AM
> Please respond to
> users_at_jersey.dev.java.net
>
>
> To
> users_at_jersey.dev.java.net
> cc
>
> Subject
> Re: [Jersey] JSON and arrays of length one
>
>
>
>
>
>
> On Fri, Nov 06, 2009 at 09:24:55AM -0600, FSauer_at_dsthealthsolutions.com
> wrote:
> > How do I get arrays of length one out of jersey's JSON marshaller?
> >
> > If some object has a List<X> and there happens to be only one element in
>
> > the collection, it comes across as" xs": {...X stuff here } instead of
> > "xs" : [{...X stuff here }]....
> > This is causing a lot of pain on the javascript side. Is there a fix for
>
> > this? Am I missing some JSON configuration perhaps?
>
> This should be described in [1]. All you need is to switch
> to "natural" json notation (see section 3.1.2.2), i.e. to implement your
> own
> JAXBContext resolver (see example 3.4, [2]).
>
> HTH,
>
> ~Jakub
>
> [1]https://jersey.dev.java.net/documentation/1.1.3-ea/user-guide.html#d4e536
> [2]https://jersey.dev.java.net/documentation/1.1.3-ea/user-guide.html#json.jaxb.context.resolver.example
>
> >
> >
> > Thanks,
> >
> >
> > Frank Sauer
> > Principal Architect
> > DST Health Solutions
> > 2500 Corporate Drive
> > Birmingham, AL 35242
> > (205)437-5204 (Office) (Direct)
> > (205)568-4684 (Cell)
> > fsauer_at_dsthealthsolutions.com
> > It is impossible to sharpen a pencil with a blunt axe. It is equally
> vain
> > to try to do it with ten blunt axes instead -- Edsger W. Dijkstra
> >
> >
> > -----------------------------------------
> > Please consider the environment before printing this email and any
> > attachments.
> >
> > This e-mail and any attachments are intended only for the
> > individual or company to which it is addressed and may contain
> > information which is privileged, confidential and prohibited from
> > disclosure or unauthorized use under applicable law. If you are
> > not the intended recipient of this e-mail, you are hereby notified
> > that any use, dissemination, or copying of this e-mail or the
> > information contained in this e-mail is strictly prohibited by the
> > sender. If you have received this transmission in error, please
> > return the material received to the sender and delete all copies
> > from your system.
>
>
>
> --
> Jakub Podlešák
> Software Engineer at SUN Microsystems And CZJUG Co-Leader
> http://blogs.sun.com/japod
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>

-- 
Jakub Podlešák
Software Engineer at SUN Microsystems And CZJUG Co-Leader
http://blogs.sun.com/japod