Package com.aliucord.utils
Object GsonUtils
-
- All Implemented Interfaces:
public class GsonUtils
-
-
Field Summary
Fields Modifier and Type Field Description private final Gsongsonprivate final GsongsonPrettyprivate final 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 GsongetGson()final GsongetGsonPretty()final GsongetGsonRestApi()-
-
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- Returns:
Deserialized JSON
-
fromJson
@Deprecated(message = "Use kt extension for Gson", replaceWith = @ReplaceWith(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- Returns:
Deserialized JSON
-
fromJson
@Deprecated(message = "Use kt extension for Gson", replaceWith = @ReplaceWith(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- Returns:
Deserialized JSON
-
fromJson
@Deprecated(message = "Use kt extension for Gson", replaceWith = @ReplaceWith(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- Returns:
Serialized JSON
-
toJson
@Deprecated(message = "Use kt extension for Gson", replaceWith = @ReplaceWith(expression = "gson.toJson(obj)")) final static String toJson(Object obj)
-
toJsonPretty
@Deprecated(message = "Use kt extension for Gson", replaceWith = @ReplaceWith(expression = "gsonPretty.toJson(obj)")) final static String toJsonPretty(Object obj)
Serializes an Object to pretty printed JSON
- Parameters:
obj- The object to serialize- Returns:
Serialized JSON
-
getGson
final Gson getGson()
-
getGsonPretty
final Gson getGsonPretty()
-
getGsonRestApi
final Gson getGsonRestApi()
-
-
-
-