Class JsonReadWriteUtils
java.lang.Object
edu.university.ecs.lab.common.utils.JsonReadWriteUtils
Utility class for reading and writing JSON to a file.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
readFromJSON
(String filePath, Class<T> type) Reads a JSON file from a given path and converts it into an object of the specified type.static <T> void
writeToJSON
(String filePath, T object) Writes an object to a JSON file at a specified path.
-
Method Details
-
writeToJSON
Writes an object to a JSON file at a specified path.- Type Parameters:
T
- the type of the object to write- Parameters:
object
- the object to serialize into JSONfilePath
- the file path where the JSON should be saved
-
readFromJSON
Reads a JSON file from a given path and converts it into an object of the specified type.- Type Parameters:
T
- the type of the object to return- Parameters:
filePath
- the file path to the JSON filetype
- the Class representing the type of the object to deserialize- Returns:
- an object of type T containing the data from the JSON file
-