I\'m building a RESTful API and I have a use case where I need to be able to render two different views of my data. One that we can use internally and one that we will expo
I was able to get this working by adding a new library to override the default:
<!-- Used to Convert our objects to JSON and XML -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>aalto-xml</artifactId>
<version>0.9.8</version>
</dependency>
So now I can serialize to JSON and XML using Jackson and their @JsonView functionality. Very clean! The one I added was aalto-xml.
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
EclipseLink JAXB (MOXy) offers an external mapping file. This mapping file can augment or completely replace the metadata supplied via annotations. Below is an example where the same object model is mapped to two different weather services (Google and Yahoo)
MOXy also supports both XML and JSON binding:
MOXy also integrates easily with JAX-RS implementations: