java.lang.Object
io.github.astrapi69.gson.JsonFileToObjectExtensions
The class
JsonFileToObjectExtensions
converts json strings to java object and java
collections.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Transforms the given json file into a java objectstatic <T> T
Transforms the given json file into a java object.static <T> List<T>
toObjectList
(File jsonListFile, Class<T> clazz) Transforms the given json file into a java List objectstatic <T> List<T>
toObjectList
(File jsonListFile, Class<T> clazz, com.google.gson.Gson gson) Transforms the given json file into a java List object
-
Method Details
-
toObject
Transforms 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:
IOException
- Signals that an I/O exception has occurred
-
toObject
public static <T> T toObject(File jsonFile, Class<T> clazz, com.google.gson.Gson gson) throws IOException Transforms 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:
IOException
- Signals that an I/O exception has occurred
-
toObjectList
Transforms 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:
IOException
- Signals that an I/O exception has occurred
-
toObjectList
public static <T> List<T> toObjectList(File jsonListFile, Class<T> clazz, com.google.gson.Gson gson) throws IOException Transforms 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:
IOException
- Signals that an I/O exception has occurred
-