Class GsonTool

java.lang.Object
io.datarouter.gson.GsonTool

public class GsonTool extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.google.gson.Gson
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.gson.GsonBuilder
    builder(EnumTypeAdapterFactory enumTypeAdapterFactory)
     
    static com.google.gson.GsonBuilder
    This can be used if you don't expect to serialize any enums and would like an error if an enum is found
    static final com.google.gson.Gson
    Quick solution for printing a value that is not parsed by another system.
    static final com.google.gson.Gson
    Quick solution for pretty-printing a value that is not parsed by another system.
    static String
     
    static com.google.gson.Gson
     
    static com.google.gson.Gson
    Deprecated.
    This is for a quick check to see if any enums are being serialized.

    Methods inherited from class java.lang.Object

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

    • GSON

      public static final com.google.gson.Gson GSON
  • Constructor Details

    • GsonTool

      public GsonTool()
  • Method Details

    • builder

      public static com.google.gson.GsonBuilder builder(EnumTypeAdapterFactory enumTypeAdapterFactory)
    • withoutEnums

      public static com.google.gson.Gson withoutEnums()
    • builderWithoutEnums

      public static com.google.gson.GsonBuilder builderWithoutEnums()
      This can be used if you don't expect to serialize any enums and would like an error if an enum is found
    • withUnregisteredEnums

      @Deprecated public static com.google.gson.Gson withUnregisteredEnums()
      Deprecated.
      This is for a quick check to see if any enums are being serialized. If so it should be replaced with a dedicated subclass of EnumTypeAdapterFactory. If not it should be replaced with GsonTool.withoutEnums().
    • forLogsPretty

      public static final com.google.gson.Gson forLogsPretty()
      Quick solution for pretty-printing a value that is not parsed by another system. Lacks things like enum validation.
    • forLogs

      public static final com.google.gson.Gson forLogs()
      Quick solution for printing a value that is not parsed by another system. Lacks things like enum validation.
    • prettyPrint

      public static String prettyPrint(String json)