public final class JsonToObjectExtensions extends Object
JsonToObjectExtensions converts json strings to java object and java
collections.| Constructor and Description |
|---|
JsonToObjectExtensions() |
| Modifier and Type | Method and Description |
|---|---|
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> Collection<T> |
toObjectCollection(String jsonString,
Class<? extends Collection> collectionClass,
Class<T> elementClass)
Transforms the given json string into a java object
Collection |
static <T> List<T> |
toObjectList(String jsonString,
Class<T> elementClass)
Transforms the given json string into a java object
List |
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> elementClass) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
ListT - the generic type of the return typejsonString - the json stringelementClass - the element class 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> Collection<T> toObjectCollection(String jsonString, Class<? extends Collection> collectionClass, Class<T> elementClass) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
CollectionT - the generic type of the return typejsonString - the json stringcollectionClass - the collection classelementClass - the element classcom.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 occurredCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.