public final class JsonTransformer extends Object
| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Gets the object mapper.
|
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper(boolean newMapper)
Gets the object mapper.
|
static <T> String |
toJson(List<T> list)
Creates from the given
List to a json string. |
static <T> String |
toJson(T object)
Creates from the given Object a json string.
|
static <T> String |
toJson(T object,
boolean newMapper)
To json.
|
static <T> String |
toJsonQuietly(T object)
Creates from the given Object a json string.
|
static <T> T |
toObject(String jsonString,
Class<T> clazz)
Transforms the given json string into a java object.
|
static <T> T |
toObject(String jsonString,
Class<T> clazz,
boolean newMapper)
Transforms the given json string into a java object.
|
static <T> T |
toObject(String jsonString,
Class<T> clazz,
com.fasterxml.jackson.databind.Module... modules)
Transforms the given json string into a java object.
|
static <T> List<T> |
toObjectList(String jsonString,
Class<T> clazz)
Transforms the given json string into a java object list.
|
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper(boolean newMapper)
newMapper - flag that indicates if a new ObjectMapper should be created. if true a new
ObjectMapper will be created otherwise the ObjectMapper from this class will be
returned.public static <T> String toJson(List<T> list) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
List to a json string.T - the generic typelist - the listcom.fasterxml.jackson.core.JsonGenerationException - If an error occurs by writing json stringcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into ObjectIOException - Signals that an I/O exception has occurred.public static <T> String toJson(T object) throws com.fasterxml.jackson.core.JsonProcessingException
T - the generic type of the given argumentobject - the object.com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to Stringpublic static <T> String toJson(T object, boolean newMapper) throws com.fasterxml.jackson.core.JsonProcessingException
T - the generic typeobject - the objectnewMapper - flag that indicates if a new ObjectMapper should be created. if true a new
ObjectMapper will be created otherwise the ObjectMapper from this class will be
returned.com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to Stringpublic static <T> String toJsonQuietly(T object)
T - the generic type of the given argumentobject - the object.public static <T> T toObject(String jsonString, Class<T> clazz) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typecom.fasterxml.jackson.core.JsonParseException - If an error occurs when parsing the string into Objectcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into ObjectIOException - Signals that an I/O exception has occurred.public static <T> T toObject(String jsonString, Class<T> clazz, boolean newMapper) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typenewMapper - flag that indicates if a new ObjectMapper should be created. if true a new
ObjectMapper will be created otherwise the ObjectMapper from this class will be
returned.com.fasterxml.jackson.core.JsonParseException - If an error occurs when parsing the string into Objectcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into ObjectIOException - Signals that an I/O exception has occurred.public static <T> T toObject(String jsonString, Class<T> clazz, com.fasterxml.jackson.databind.Module... modules) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typemodules - The modules to register for the mappercom.fasterxml.jackson.core.JsonParseException - If an error occurs when parsing the string into Objectcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into ObjectIOException - Signals that an I/O exception has occurred.public static <T> List<T> toObjectList(String jsonString, Class<T> clazz) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typecom.fasterxml.jackson.core.JsonParseException - If an error occurs when parsing the string into Objectcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into ObjectIOException - Signals that an I/O exception has occurred.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.