Package io.github.astrapi69.gson
Class JsonStringToObjectExtensions
- java.lang.Object
-
- io.github.astrapi69.gson.JsonStringToObjectExtensions
-
public final class JsonStringToObjectExtensions extends java.lang.Object
The classJsonStringToObjectExtensions
converts json strings to java object and java collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
java.util.Map<K,V>toMapObject(java.lang.String jsonString, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
Transforms the given json string into a java map objectstatic <K,V>
java.util.Map<K,V>toMapObject(java.lang.String jsonString, java.lang.Class<K> keyType, java.lang.Class<V> valueType, com.google.gson.Gson gson)
Transforms the given json string into a java map objectstatic <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, com.google.gson.Gson gson)
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 objectCollection
static <T> java.util.Collection<T>
toObjectCollection(java.lang.String jsonString, java.lang.Class<? extends java.util.Collection> collectionClass, java.lang.Class<T> elementClass, com.google.gson.Gson gson)
Transforms the given json string into a java objectCollection
static <T> java.util.List<T>
toObjectList(java.lang.String jsonString, java.lang.Class<T> elementClass)
Transforms the given json string into a java objectList
-
-
-
Method Detail
-
toMapObject
public static <K,V> java.util.Map<K,V> toMapObject(java.lang.String jsonString, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
Transforms the given json string into a java map object- Type Parameters:
K
- the generic type of keysV
- the generic type of values- Parameters:
jsonString
- the json stringkeyType
- the class type of the keyvalueType
- the class type of the value- Returns:
- the map
-
toMapObject
public static <K,V> java.util.Map<K,V> toMapObject(java.lang.String jsonString, java.lang.Class<K> keyType, java.lang.Class<V> valueType, com.google.gson.Gson gson)
Transforms the given json string into a java map object- Type Parameters:
K
- the generic type of keysV
- the generic type of values- Parameters:
jsonString
- the json stringkeyType
- the class type of the keyvalueType
- the class type of the valuegson
- the gson object- Returns:
- the map
-
toObject
public static <T> T toObject(java.lang.String jsonString, java.lang.Class<T> clazz)
Transforms the given json string into a java object.- Type Parameters:
T
- the generic type of the return type- Parameters:
jsonString
- the json stringclazz
- the clazz of the generic type- Returns:
- the object
-
toObject
public static <T> T toObject(java.lang.String jsonString, java.lang.Class<T> clazz, com.google.gson.Gson gson)
Transforms the given json string into a java object.- Type Parameters:
T
- the generic type of the return type- Parameters:
jsonString
- the json stringclazz
- the clazz of the generic typegson
- the gson object- Returns:
- the object
-
toObjectCollection
public 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 objectCollection
- Type Parameters:
T
- the generic type of the return type- Parameters:
jsonString
- the json stringcollectionClass
- the collection classelementClass
- the element class- Returns:
- the list with the java objects.
-
toObjectCollection
public static <T> java.util.Collection<T> toObjectCollection(java.lang.String jsonString, java.lang.Class<? extends java.util.Collection> collectionClass, java.lang.Class<T> elementClass, com.google.gson.Gson gson)
Transforms the given json string into a java objectCollection
- Type Parameters:
T
- the generic type of the return type- Parameters:
jsonString
- the json stringcollectionClass
- the collection classelementClass
- the element classgson
- the gson object- Returns:
- the list with the java objects
-
toObjectList
public static <T> java.util.List<T> toObjectList(java.lang.String jsonString, java.lang.Class<T> elementClass)
Transforms the given json string into a java objectList
- Type Parameters:
T
- the generic type of the return type- Parameters:
jsonString
- the json stringelementClass
- the element class of the generic type- Returns:
- the list with the java objects
-
-