Web common
RESThub Web Common comes with built-in XML and JSON support for serialization based on Jackson 2.4.2 documentation. RESThub uses Jackson 2 XML capabilities instead of JAXB since it is more flexible. For example, you don’t need to add classes to a context. Please read Jackson annotation guide for details about configuration capabilities.
Maven dependency
In order to use it in your project, add the following snippet to your pom.xml:
<dependency>
<groupId>org.resthub</groupId>
<artifactId>resthub-web-common</artifactId>
<version>2.2.0</version>
</dependency>
Usage
// JSON
SampleResource r = (SampleResource) JsonHelper.deserialize(json, SampleResource.class);
JsonHelper.deserialize("{\"id\": 123, \"name\": \"Albert\", \"description\": \"desc\"}", SampleResource.class);
// XML
SampleResource r = (SampleResource) XmlHelper.deserialize(xml, SampleResource.class);
XmlHelper.deserialize("<sampleResource><description>desc</description><id>123</id><name>Albert</name></sampleResource>", SampleResource.class);