users@jersey.java.net

Re: [Jersey] How to append extra informaion to generated json

From: Andrew Ochsner <aochsner_at_cs.stanford.edu>
Date: Wed, 22 Apr 2009 08:23:54 -0500

Yeah, we've done the approach of a "container" class. Our requirement is to
support the OpenSocial/OpenSearch specs...and that's more about the total
size of the results but "paged" so you only get a subset of the total...

On Tue, Apr 21, 2009 at 9:17 PM, Chris Winters <chris.winters_at_gmail.com>wrote:

> I think you need to create another object to do this. Something like:
>
> @XmlRootElement
> class MyItemContainer {
>
> @XmlElement
> private final List<MyItem> items;
>
> public MyItemContainer( final List<MyItem> contained ) {
> this.items = new ArrayList<MyItem>( contained );
> }
>
> @XmlAttribute( name = "total" )
> public int getSize() {
> return items.size();
> }
> }
>
> Chris
>
> On Tue, Apr 21, 2009 at 2:37 PM, Patel, Sanjay <sapatel_at_nemours.org>
> wrote:
> > Hey,
> >
> > I am using jersey/jaxb to convert my list of objects to JSON. I want to
> add
> > extra property to my generated JSON (e.g "total": total_objects_in_list).
> > How can I do that??
> >
> > Sanjay
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>