Package 

Class GsonUtils

    • Method Detail

      • setGsonDelegate

         static void setGsonDelegate(Gson delegate)

        Set the delegate of Gson.

        Parameters:
        delegate - The delegate of Gson.
      • setGson

         static void setGson(String key, Gson gson)

        Set the Gson with key.

        Parameters:
        key - The key.
        gson - The Gson.
      • getGson

         static Gson getGson(String key)

        Return the Gson with key.

        Parameters:
        key - The key.
      • toJson

         static String toJson(Object object)

        Serializes an object into json.

        Parameters:
        object - The object to serialize.
      • toJson

         static String toJson(Object src, @NonNull() Type typeOfSrc)

        Serializes an object into json.

        Parameters:
        src - The object to serialize.
        typeOfSrc - The specific genericized type of src.
      • toJson

         static String toJson(@NonNull() Gson gson, Object object)

        Serializes an object into json.

        Parameters:
        gson - The gson.
        object - The object to serialize.
      • toJson

         static String toJson(@NonNull() Gson gson, Object src, @NonNull() Type typeOfSrc)

        Serializes an object into json.

        Parameters:
        gson - The gson.
        src - The object to serialize.
        typeOfSrc - The specific genericized type of src.
      • fromJson

         static <T> T fromJson(String json, @NonNull() Class<T> type)

        Converts String to given type.

        Parameters:
        json - The json to convert.
        type - Type json will be converted to.
      • fromJson

         static <T> T fromJson(String json, @NonNull() Type type)

        Converts String to given type.

        Parameters:
        json - the json to convert.
        type - type type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Reader reader, @NonNull() Class<T> type)

        Converts Reader to given type.

        Parameters:
        reader - the reader to convert.
        type - type type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Reader reader, @NonNull() Type type)

        Converts Reader to given type.

        Parameters:
        reader - the reader to convert.
        type - type type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Gson gson, String json, @NonNull() Class<T> type)

        Converts String to given type.

        Parameters:
        gson - The gson.
        json - The json to convert.
        type - Type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Gson gson, String json, @NonNull() Type type)

        Converts String to given type.

        Parameters:
        gson - The gson.
        json - the json to convert.
        type - type type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Gson gson, Reader reader, @NonNull() Class<T> type)

        Converts Reader to given type.

        Parameters:
        gson - The gson.
        reader - the reader to convert.
        type - type type json will be converted to.
      • fromJson

         static <T> T fromJson(@NonNull() Gson gson, Reader reader, @NonNull() Type type)

        Converts Reader to given type.

        Parameters:
        gson - The gson.
        reader - the reader to convert.
        type - type type json will be converted to.
      • getMapType

         static Type getMapType(@NonNull() Type keyType, @NonNull() Type valueType)

        Return the type of map with the {@code keyType} and {@code valueType}.

        Parameters:
        keyType - The type of key.
        valueType - The type of value.
      • getArrayType

         static Type getArrayType(@NonNull() Type type)

        Return the type of array with the {@code type}.

        Parameters:
        type - The type.
      • getType

         static Type getType(@NonNull() Type rawType, @NonNull() Array<Type> typeArguments)

        Return the type of {@code rawType} with the {@code typeArguments}.

        Parameters:
        rawType - The raw type.
        typeArguments - The type of arguments.