Package com.aliucord.utils
Object GsonUtils
-
- All Implemented Interfaces:
public class GsonUtils
-
-
Field Summary
Fields Modifier and Type Field Description private final static Gson
gson
private final static Gson
gsonPretty
private final static Gson
gsonRestApi
public final static GsonUtils
INSTANCE
-
Method Summary
Modifier and Type Method Description final static <T extends Any> T
fromJson(Gson $self, String json, Class<T> clazz)
Deserializes a JSON string into the specified class final static <T extends Any> T
fromJson(String json, Class<T> clazz)
final static <T extends Any> T
fromJson(Gson $self, Reader reader, Class<T> clazz)
Deserializes a JSON string into the specified class final static <T extends Any> T
fromJson(Reader reader, Class<T> clazz)
final static <T extends Any> T
fromJson(Gson $self, String json, Type type)
Deserializes a JSON string into the specified object final static <T extends Any> T
fromJson(String json, Type type)
final static String
toJson(Gson $self, Object obj)
Serializes an Object to JSON final static String
toJson(Object obj)
final static String
toJsonPretty(Object obj)
Serializes an Object to pretty printed JSON final static Gson
getGson()
Gson instance final static Gson
getGsonPretty()
Gson instance with pretty print enabled final static Gson
getGsonRestApi()
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
-
-
-
-