public final class JsonUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
convert(Object object,
Class<T> valueType) |
static <T> T |
convert(Object object,
com.fasterxml.jackson.core.type.TypeReference<T> reference) |
static <T> T |
fromJson(String json,
Class<T> valueType)
Transforms String to JSON object
|
static <T> T |
fromJson(String json,
Class<T> valueType,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Allows de-serialization with custom mapping
|
static <T> T |
fromJson(String json,
com.fasterxml.jackson.core.type.TypeReference<T> reference) |
static <T> T |
fromJson(String json,
com.fasterxml.jackson.core.type.TypeReference<T> reference,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Allows de-serialization with custom mapping
|
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Returns a thread-local instance of JSON ObjectMapper.
|
static String |
toJson(Object object)
Converts object to JSON string
|
static String |
toJson(Object object,
com.fasterxml.jackson.databind.ObjectMapper customMapper)
Allows JSON serialization with custom mapping
|
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public static String toJson(Object object)
object - to be convertedpublic static String toJson(Object object, com.fasterxml.jackson.databind.ObjectMapper customMapper)
object - to be serializedcustomMapper - custom mapperpublic static <T> T fromJson(String json, Class<T> valueType)
T - class typejson - string to transformvalueType - class typepublic static <T> T fromJson(String json, com.fasterxml.jackson.core.type.TypeReference<T> reference)
T - class typejson - JSON representation of objectreference - type referencepublic static <T> T fromJson(String json, com.fasterxml.jackson.core.type.TypeReference<T> reference, com.fasterxml.jackson.databind.ObjectMapper mapper)
T - class typejson - JSON representation of objectreference - type referencemapper - custom object mapperpublic static <T> T fromJson(String json, Class<T> valueType, com.fasterxml.jackson.databind.ObjectMapper mapper)
T - class typejson - JSON representation of objectvalueType - classmapper - custom object mapperpublic static <T> T convert(Object object, com.fasterxml.jackson.core.type.TypeReference<T> reference)
T - class typeobject - JSON representation of objectreference - type referenceCopyright © 2015–2016. All rights reserved.