JSON is a lightweight format used to traverse the network. It is easy to parse and generate a JSON format from POJOs and Java types. The following modules are supported by Jersey JSON:
MOXy
Java API for JSON Processing (JSON-P)
Jackson
Jettison
Let's look at each in turns.
The MOXy component allows developers to bind POJOs to XML or JSON formats. It automatically formats data without any explicit configuration. This MOXy feature is automatically discovered when you add the jersey-media module in an application. MOXy combines with JAXB and manages to convert data to and fro. Let's check how we can use MOXy in our application:
public class App extends ResourceConfig { public App() { packages("com.chapter4").register (new JsonMoxyConfigurationContextResolver()); } @Provider final static class JsonMoxyConfigurationContextResolver implements ContextResolver<MoxyJsonConfig> { @Override public MoxyJsonConfig getContext(Class<?...