Converting JSON object to a generic class with Jackson

Marshaling a Java Object to JSON is very straight forward. Here is a simple example that prints out the object’s JSON representation.

Converting a JSON String to a Java Object is similarly simple.

Sometimes, however, it is necessary to unmarshal a JSON object into a generic class. To do that we need to use TypeReference.class.

To convert JSON to a more complicated object, for example a list List<MyObject> we would need to construct a collection type. API Doc JavaType.class

For more information refer to the official Jackson Main Page.