Class GsonHelper

java.lang.Object
org.eclipse.dirigible.commons.api.helpers.GsonHelper

public class GsonHelper
extends Object
The GsonHelper utility class.
  • Constructor Details

  • Method Details

    • toJson

      public static String toJson​(Object src)
      To json.
      Parameters:
      src - the src
      Returns:
      the string
    • toJson

      public static <T> String toJson​(Object src, Class<T> classOfT)
      To json.
      Type Parameters:
      T - the generic type
      Parameters:
      src - the src
      classOfT - the class of T
      Returns:
      the string
    • fromJson

      public static <T> T fromJson​(String src, Class<T> classOfT)
      From json.
      Type Parameters:
      T - the generic type
      Parameters:
      src - the src
      classOfT - the class of T
      Returns:
      the t
    • fromJson

      public static <T> T fromJson​(InputStreamReader src, Type type)
      From json.
      Type Parameters:
      T - the generic type
      Parameters:
      src - the src
      type - the type
      Returns:
      the t
    • fromJson

      public static <T> T fromJson​(String src, Type type)
      From json.
      Type Parameters:
      T - the generic type
      Parameters:
      src - the src
      type - the type
      Returns:
      the t
    • toJsonTree

      public static com.google.gson.JsonElement toJsonTree​(Object value)
      To json tree.
      Parameters:
      value - the value
      Returns:
      the json element
    • parseJson

      public static com.google.gson.JsonElement parseJson​(String src)
      Parses the json.
      Parameters:
      src - the src
      Returns:
      the json element