public class JsonUtils
extends java.lang.Object
Constructor and Description |
---|
JsonUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
fromFile(java.io.File file,
java.lang.Class<T> type)
Read a json object from the given file, and try to cast the read object to the given class.
|
static <T> T |
fromJson(java.lang.String json,
java.lang.Class<T> type)
See
Gson.fromJson(String, Class) |
static void |
toFile(java.io.File file,
java.lang.Object obj)
Write the given object to the given file.
|
static java.lang.String |
toJson(java.lang.Object obj) |
public static <T> T fromFile(java.io.File file, java.lang.Class<T> type)
com.google.gson.JsonSyntaxException
- when there is a syntax error in this json filepublic static void toFile(java.io.File file, java.lang.Object obj)
public static java.lang.String toJson(java.lang.Object obj)
public static <T> T fromJson(java.lang.String json, java.lang.Class<T> type)
Gson.fromJson(String, Class)