public final class JsonStringToObjectExtensions
extends java.lang.Object
JsonStringToObjectExtensions converts json strings to java object and java
collections.| Constructor and Description |
|---|
JsonStringToObjectExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
toObject(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<T> clazz)
Transforms the given json string into a java object.
|
static <T> T |
toObject(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<T> clazz,
boolean newMapper)
Transforms the given json string into a java object.
|
static <T> T |
toObject(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<T> clazz,
com.fasterxml.jackson.databind.Module... modules)
Transforms the given json string into a java object.
|
static <T> T |
toObject(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<T> clazz,
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
Transforms the given json string into a java object.
|
static <T> java.util.Collection<T> |
toObjectCollection(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<? extends java.util.Collection> collectionClass,
@NonNull java.lang.Class<T> elementClass)
Transforms the given json string into a java object
Collection |
static <T> java.util.List<T> |
toObjectList(@NonNull java.lang.String jsonString,
@NonNull java.lang.Class<T> elementClass)
Transforms the given json string into a java object
List |
public static <T> T toObject(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull 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(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull 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(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull 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(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull java.lang.Class<T> clazz,
@NonNull
@NonNull 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> java.util.List<T> toObjectList(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull 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.public static <T> java.util.Collection<T> toObjectCollection(@NonNull
@NonNull java.lang.String jsonString,
@NonNull
@NonNull java.lang.Class<? extends java.util.Collection> collectionClass,
@NonNull
@NonNull 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 occurred