Interface Jsonator<T>

All Known Implementing Classes:
DefaultJsonator

public interface Jsonator<T>
Interface to implement if you want to provide a method to create a JSON representation of an object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Defines handling of Java enums during Object to JSON conversion.
  • Method Summary

    Modifier and Type
    Method
    Description
    Function<T,com.google.gson.JsonElement>
     
    com.google.gson.JsonElement
    convert(T object)
    Creates a JsonElement representation of a given object.
    com.google.gson.JsonElement
    convert(T object, Jsonator.EnumConversionMode enumConversionMode)
    Creates a JsonElement representation of a given object
  • Method Details

    • convert

      com.google.gson.JsonElement convert(T object)
      Creates a JsonElement representation of a given object. Enums are converted to their names.
      Parameters:
      object - the object to be serialized
      Returns:
      Json JSON representation of the given object
    • convert

      Function<T,com.google.gson.JsonElement> convert()
      Returns:
      a function to map objects to their JsonElements representation. Enums are converted to their names.
    • convert

      com.google.gson.JsonElement convert(T object, Jsonator.EnumConversionMode enumConversionMode)
      Creates a JsonElement representation of a given object
      Parameters:
      object - the object to be serialized
      enumConversionMode - defines enum handling
      Returns:
      Json JSON representation of the given object