-
public class GsonUtils
-
-
Field Summary
Fields Modifier and Type Field Description private final static Gsongsonprivate final static GsongsonPrettyprivate final static GsongsonRestApipublic final static GsonUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description final static <T extends Any> TfromJson(Gson $self, String json, Class<T> clazz)Deserializes a JSON string into the specified class final static <T extends Any> TfromJson(String json, Class<T> clazz)final static <T extends Any> TfromJson(Gson $self, Reader reader, Class<T> clazz)Deserializes a JSON string into the specified class final static <T extends Any> TfromJson(Reader reader, Class<T> clazz)final static <T extends Any> TfromJson(Gson $self, String json, Type type)Deserializes a JSON string into the specified object final static <T extends Any> TfromJson(String json, Type type)final static StringtoJson(Gson $self, Object obj)Serializes an Object to JSON final static StringtoJson(Object obj)final static StringtoJsonPretty(Object obj)Serializes an Object to pretty printed JSON final static GsongetGson()Gson instance final static GsongetGsonPretty()Gson instance with pretty print enabled final static GsongetGsonRestApi()Gson instance with same config as Discord uses for com.discord.utilities.rest.RestAPI -
-
Method Detail
-
fromJson
final static <T extends Any> T fromJson(Gson $self, String json, Class<T> clazz)
Deserializes a JSON string into the specified class
- Parameters:
json- The JSON string to deserializeclazz- The class to deserialize the JSON into
-
fromJson
@Deprecated(message = Use kt extension for Gson, replaceWith = @ReplaceWith(imports = {}, expression = gson.fromJson(json, clazz))) final static <T extends Any> T fromJson(String json, Class<T> clazz)
-
fromJson
final static <T extends Any> T fromJson(Gson $self, Reader reader, Class<T> clazz)
Deserializes a JSON string into the specified class
- Parameters:
reader- The reader from which JSON will be deserializedclazz- The class to deserialize the JSON into
-
fromJson
@Deprecated(message = Use kt extension for Gson, replaceWith = @ReplaceWith(imports = {}, expression = gson.fromJson(reader, clazz))) final static <T extends Any> T fromJson(Reader reader, Class<T> clazz)
-
fromJson
final static <T extends Any> T fromJson(Gson $self, String json, Type type)
Deserializes a JSON string into the specified object
- Parameters:
json- The JSON string to deserializetype- The type of the object to deserialize the JSON into
-
fromJson
@Deprecated(message = Use kt extension for Gson, replaceWith = @ReplaceWith(imports = {}, expression = gson.fromJson(json, type))) final static <T extends Any> T fromJson(String json, Type type)
-
toJson
final static String toJson(Gson $self, Object obj)
Serializes an Object to JSON
- Parameters:
obj- The object to serialize
-
toJson
@Deprecated(message = Use kt extension for Gson, replaceWith = @ReplaceWith(imports = {}, expression = gson.toJson(obj))) final static String toJson(Object obj)
-
toJsonPretty
@Deprecated(message = Use kt extension for Gson, replaceWith = @ReplaceWith(imports = {}, expression = gsonPretty.toJson(obj))) final static String toJsonPretty(Object obj)
Serializes an Object to pretty printed JSON
- Parameters:
obj- The object to serialize
-
getGsonPretty
final static Gson getGsonPretty()
Gson instance with pretty print enabled
-
getGsonRestApi
final static Gson getGsonRestApi()
Gson instance with same config as Discord uses for com.discord.utilities.rest.RestAPI
-
-
-
-