Class GsonConverter

  • All Implemented Interfaces:
    Converter


    public class GsonConverter
    extends Object
    implements Converter
    A Converter which uses GSON for serialization and deserialization of entities.
    • Constructor Detail

      • GsonConverter

        public GsonConverter(com.google.gson.Gson gson)
        Create an instance using the supplied Gson object for conversion. Encoding to JSON and decoding from JSON (when no charset is specified by a header) will use UTF-8.
      • GsonConverter

        public GsonConverter(com.google.gson.Gson gson,
                             String charset)
        Create an instance using the supplied Gson object for conversion. Encoding to JSON and decoding from JSON (when no charset is specified by a header) will use the specified charset.
    • Method Detail

      • toBody

        public TypedOutput toBody(Object object)
        Description copied from interface: Converter
        Convert an object to an appropriate representation for HTTP transport.
        Specified by:
        toBody in interface  Converter
        Parameters:
        object - Object instance to convert.
        Returns:
        Representation of the specified object as bytes.