public final class JsonStringToObjectExtensions
extends java.lang.Object
JsonStringToObjectExtensions converts json strings to java object and java
collections.| Modifier and Type | Method and Description |
|---|---|
static <K,V> java.util.Map<K,V> |
toMapObject(java.lang.String jsonString,
com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Transforms the given json string into a java map object
|
static <T> T |
toObject(java.lang.String jsonString,
java.lang.Class<T> clazz)
Transforms the given json string into a java object.
|
static <T> T |
toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
boolean newMapper)
Transforms the given json string into a java object.
|
static <T> T |
toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
com.fasterxml.jackson.databind.Module... modules)
Transforms the given json string into a java object.
|
static <T> T |
toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Transforms the given json string into a java object.
|
static <T> T |
toObject(java.lang.String jsonString,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Transforms the given json string into a java object.
|
static <T> java.util.Collection<T> |
toObjectCollection(java.lang.String jsonString,
java.lang.Class<? extends java.util.Collection> collectionClass,
java.lang.Class<T> elementClass)
Transforms the given json string into a java object
Collection |
static <T> java.util.List<T> |
toObjectList(java.lang.String jsonString,
java.lang.Class<T> elementClass)
Transforms the given json string into a java object
List |
public static <K,V> java.util.Map<K,V> toMapObject(java.lang.String jsonString,
com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference,
com.fasterxml.jackson.databind.ObjectMapper mapper)
throws java.io.IOException
K - the generic type of keysV - the generic type of valuesjsonString - the json stringtypeReference - the type referencemapper - the object mapperjava.io.IOException - Signals that an I/O exception has occurredpublic static <T> T toObject(java.lang.String jsonString,
java.lang.Class<T> clazz)
throws java.io.IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typejava.io.IOException - Signals that an I/O exception has occurred.public static <T> T toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
boolean newMapper)
throws java.io.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.java.io.IOException - Signals that an I/O exception has occurred.public static <T> T toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
com.fasterxml.jackson.databind.Module... modules)
throws java.io.IOException
T - the generic type of the return typejsonString - the json stringclazz - the clazz of the generic typemodules - The modules to register for the mapperjava.io.IOException - Signals that an I/O exception has occurred.public static <T> T toObject(java.lang.String jsonString,
java.lang.Class<T> clazz,
com.fasterxml.jackson.databind.ObjectMapper mapper)
throws java.io.IOException
T - the generic typejsonString - the json stringclazz - the clazz of the generic typemapper - the object mapperjava.io.IOException - Signals that an I/O exception has occurredpublic static <T> T toObject(java.lang.String jsonString,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
com.fasterxml.jackson.databind.ObjectMapper mapper)
throws java.io.IOException
T - the generic typejsonString - the json stringtypeReference - the type referencemapper - the object mapperjava.io.IOException - Signals that an I/O exception has occurredpublic static <T> java.util.Collection<T> toObjectCollection(java.lang.String jsonString,
java.lang.Class<? extends java.util.Collection> collectionClass,
java.lang.Class<T> elementClass)
throws java.io.IOException
CollectionT - the generic type of the return typejsonString - the json stringcollectionClass - the collection classelementClass - the element classjava.io.IOException - Signals that an I/O exception has occurredpublic static <T> java.util.List<T> toObjectList(java.lang.String jsonString,
java.lang.Class<T> elementClass)
throws java.io.IOException
ListT - the generic type of the return typejsonString - the json stringelementClass - the element class of the generic typejava.io.IOException - Signals that an I/O exception has occurred.