users@jersey.java.net

Omitting fields on some requests

From: Mike Boyers <mboyers_at_yahoo.com>
Date: Mon, 21 Jun 2010 14:36:05 -0700 (PDT)

Using Jersey, I'm producing a JSON response that's an array of objects. The object in question has about 25 fields.

There are some cases where I want to return an array of these objects and include every one of the object's fields in the response.

However, there are also cases where I'd like to produce an abbreviated response that only contains a subset of the fields from the object.

I'm trying to find a way to do this without having to make a different POJO for the abbreviated response.

The only thing I've found so far is the @XmlTransient annotation, which is sort of along the same lines of what I'm looking for, but I'm looking for a way to do it conditionally.

Thanks,
Mike