users@jersey.java.net

[Jersey] One domain model, multiple json views

From: <rick_at_broadcastr.com>
Date: Sat, 26 May 2012 18:26:24 +0000 (GMT)

Hi, I asked this question on stackoverflow, but thought I would send it
here as well..

We have a set of domain classes which are serialized to json via
jackson using jersey services. We are currently annotating the classes
with JAXB (although we're not tied to that). This works fine. But we
want to offer different serializations of the classes for different use
cases.

Web site
Mobile apps
Admin tool
Public API

In each of these use cases there are different fields which we may or
may not want included in the json view. For example, the admin tool
might need some parameters for setting permissions on data. The mobile
client needs a different URL to a media stream than the website. The
website has particular naming conventions it needs for fields.

What is the best practice for managing different mappings of json for
different service endpoints in Jersey?

Thanks!