Object GsonUtils

  • All Implemented Interfaces:

    
    public class GsonUtils
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 deserialize
        clazz - The class to deserialize the JSON into
      • 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 deserialized
        clazz - The class to deserialize the JSON into
      • 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 deserialize
        type - The type of the object to deserialize the JSON into
      • toJson

         final static String toJson(Gson $self, Object obj)

        Serializes an Object to JSON

        Parameters:
        obj - The object to serialize
      • 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