Package io.github.astrapi69.gson
Class JsonFileToObjectExtensions
- java.lang.Object
-
- io.github.astrapi69.gson.JsonFileToObjectExtensions
-
public final class JsonFileToObjectExtensions extends java.lang.ObjectThe classJsonFileToObjectExtensionsconverts json strings to java object and java collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TtoObject(java.io.File jsonFile, java.lang.Class<T> clazz)Transforms the given json file into a java objectstatic <T> TtoObject(java.io.File jsonFile, java.lang.Class<T> clazz, com.google.gson.Gson gson)Transforms the given json file into a java object.static <T> java.util.List<T>toObjectList(java.io.File jsonListFile, java.lang.Class<T> clazz)Transforms the given json file into a java List objectstatic <T> java.util.List<T>toObjectList(java.io.File jsonListFile, java.lang.Class<T> clazz, com.google.gson.Gson gson)Transforms the given json file into a java List object
-
-
-
Method Detail
-
toObject
public static <T> T toObject(java.io.File jsonFile, java.lang.Class<T> clazz) throws java.io.IOExceptionTransforms the given json file into a java object- Type Parameters:
T- the generic type- Parameters:
jsonFile- the json fileclazz- the class- Returns:
- the java object
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObject
public static <T> T toObject(java.io.File jsonFile, java.lang.Class<T> clazz, com.google.gson.Gson gson) throws java.io.IOExceptionTransforms the given json file into a java object.- Type Parameters:
T- the generic type- Parameters:
jsonFile- the json fileclazz- the classgson- the gson object- Returns:
- the java object
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObjectList
public static <T> java.util.List<T> toObjectList(java.io.File jsonListFile, java.lang.Class<T> clazz) throws java.io.IOExceptionTransforms the given json file into a java List object- Type Parameters:
T- the generic type- Parameters:
jsonListFile- the json file with an arrayclazz- the class- Returns:
- the list
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObjectList
public static <T> java.util.List<T> toObjectList(java.io.File jsonListFile, java.lang.Class<T> clazz, com.google.gson.Gson gson) throws java.io.IOExceptionTransforms the given json file into a java List object- Type Parameters:
T- the generic type- Parameters:
jsonListFile- the json file with an arrayclazz- the classgson- the gson object- Returns:
- the list
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
-