Class GsonJson

java.lang.Object
net.odoframework.container.GsonJson
All Implemented Interfaces:
Runnable, Json

@Singleton
public class GsonJson
extends Object
implements Json, Runnable
Gson service proder for Json
  • Constructor Details

    • GsonJson

      public GsonJson()
    • GsonJson

      public GsonJson​(boolean prettyPrint)
  • Method Details

    • marshal

      public String marshal​(Object instance)
      Description copied from interface: Json
      Marshals an instance of an object to a String
      Specified by:
      marshal in interface Json
      Parameters:
      instance - to marshal to string, will throw NullPointerException if the parameter is null
      Returns:
      and instance of the instance parameter in a JSON string
    • unmarshal

      public <T> T unmarshal​(String json, Class<T> target)
      Description copied from interface: Json
      Converts a json string into an instance of the given target type
      Specified by:
      unmarshal in interface Json
      Type Parameters:
      T - the return type of the class
      Parameters:
      json - String of JSON to convert
      target - type of the target to convert the json to
      Returns:
      an instance of the converted json string
    • run

      public void run()
      Specified by:
      run in interface Runnable