public class JsonHelper extends Object
Modifier and Type | Field and Description |
---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
objectMapper
Jackson Object Mapper used to serialization/deserialization
|
Constructor and Description |
---|
JsonHelper() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
deserialize(String content,
Class<T> type)
Deserialize a JSON string
|
static <T> T |
deserialize(String content,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
Deserialize a JSON string
|
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Return the ObjectMapper.
|
protected static void |
initialize() |
static String |
serialize(Object o)
Serialize and object to a JSON String representation
|
static String |
serialize(Object o,
Class<?> view)
Serialize and object to a JSON String representation with a Jackson view
|
protected static com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected static void initialize()
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public static String serialize(Object o)
o
- The object to serializepublic static String serialize(Object o, Class<?> view)
o
- The object to serializeview
- The Jackson view to usepublic static <T> T deserialize(String content, Class<T> type)
content
- The JSON String object representationtype
- The type of the deserialized object instancepublic static <T> T deserialize(String content, com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
content
- The JSON String object representationvalueTypeRef
- The typeReference containing the type of the deserialized object instanceCopyright © 2009–2014. All rights reserved.