Package sh.ory

Class JSON

java.lang.Object
sh.ory.JSON

public class JSON
extends Object
  • Constructor Details

    • JSON

      public JSON()
  • Method Details

    • createGson

      public static com.google.gson.GsonBuilder createGson()
    • getGson

      public com.google.gson.Gson getGson()
      Get Gson.
      Returns:
      Gson
    • setGson

      public JSON setGson​(com.google.gson.Gson gson)
      Set Gson.
      Parameters:
      gson - Gson
      Returns:
      JSON
    • setLenientOnJson

      public JSON setLenientOnJson​(boolean lenientOnJson)
      Configure the parser to be liberal in what it accepts.
      Parameters:
      lenientOnJson - Set it to true to ignore some syntax errors
      Returns:
      JSON
      See Also:
      https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
    • serialize

      public String serialize​(Object obj)
      Serialize the given Java object into JSON string.
      Parameters:
      obj - Object
      Returns:
      String representation of the JSON
    • deserialize

      public <T> T deserialize​(String body, Type returnType)
      Deserialize the given JSON string to Java object.
      Type Parameters:
      T - Type
      Parameters:
      body - The JSON string
      returnType - The type to deserialize into
      Returns:
      The deserialized Java object
    • setOffsetDateTimeFormat

      public JSON setOffsetDateTimeFormat​(DateTimeFormatter dateFormat)
    • setLocalDateFormat

      public JSON setLocalDateFormat​(DateTimeFormatter dateFormat)
    • setDateFormat

      public JSON setDateFormat​(DateFormat dateFormat)
    • setSqlDateFormat

      public JSON setSqlDateFormat​(DateFormat dateFormat)