users@jersey.java.net

[Jersey] Re: How to post only selective fields using the client

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Mon, 15 Oct 2012 09:22:51 -0700

On Mon, Oct 15, 2012 at 8:20 AM, Jaco le Roux <jabalsad_at_gmail.com> wrote:
> Hi,
>
> When POSTing a Java object as JSON to a RESTful service, the entire
> object gets serialized into the request. Is there a way to choose
> which member variables get converted to JSON?

For general approaches to filtering (out) of properties with Jackson, see:

http://www.cowtowncoder.com/blog/archives/2011/02/entry_443.html

there is no annotation based way to tie it all together -- thing with
annotations is that annotations & dynamic do not really mix, so you
are working against the grain -- but you can easily do it explicitly
with ObjectMapper and StreamingOutput.

Alternatively what is often done is to "serialize" object into Map or
JsonNode first, filtering either during or after, and then returning
that structure for Jersey to serialize into JSON or XML.

-+ Tatu +-