Class GsonUtils

java.lang.Object
me.hsgamer.hscore.gson.GsonUtils

public final class GsonUtils extends Object
Some utilities for Gson
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<com.google.gson.JsonElement>
    getElements(com.google.gson.JsonArray array)
    Get the elements from a JsonArray
    static Map<String,com.google.gson.JsonElement>
    getElements(com.google.gson.JsonObject object)
    Get the elements from a JsonObject
    static boolean
    isEmpty(com.google.gson.JsonArray array)
    Check if the JsonArray is empty
    static Object
    normalize(com.google.gson.JsonElement element, boolean deep)
    Normalize the JsonElement to the object
    static com.google.gson.JsonElement
    parse(com.google.gson.stream.JsonReader reader)
    Parse a reader to JsonElement
    static com.google.gson.JsonElement
    parse(Reader reader)
    Parse a reader to JsonElement
    static com.google.gson.JsonElement
    parse(String string)
    Parse a string to JsonElement

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static com.google.gson.JsonElement parse(String string)
      Parse a string to JsonElement
      Parameters:
      string - the string
      Returns:
      the JsonElement
    • parse

      public static com.google.gson.JsonElement parse(Reader reader)
      Parse a reader to JsonElement
      Parameters:
      reader - the reader
      Returns:
      the JsonElement
    • parse

      public static com.google.gson.JsonElement parse(com.google.gson.stream.JsonReader reader)
      Parse a reader to JsonElement
      Parameters:
      reader - the reader
      Returns:
      the JsonElement
    • getElements

      public static List<com.google.gson.JsonElement> getElements(com.google.gson.JsonArray array)
      Get the elements from a JsonArray
      Parameters:
      array - the array
      Returns:
      the elements
    • isEmpty

      public static boolean isEmpty(com.google.gson.JsonArray array)
      Check if the JsonArray is empty
      Parameters:
      array - the array
      Returns:
      true if it is empty
    • getElements

      public static Map<String,com.google.gson.JsonElement> getElements(com.google.gson.JsonObject object)
      Get the elements from a JsonObject
      Parameters:
      object - the object
      Returns:
      the elements
    • normalize

      public static Object normalize(com.google.gson.JsonElement element, boolean deep)
      Normalize the JsonElement to the object
      Parameters:
      element - the element
      deep - whether to normalize the nested elements
      Returns:
      the normalized object