retrofit.converter
Class GsonConverter

java.lang.Object
  extended by retrofit.converter.GsonConverter
All Implemented Interfaces:
Converter

public class GsonConverter
extends Object
implements Converter

A Converter which uses GSON for serialization and deserialization of entities.

Author:
Jake Wharton ([email protected])

Constructor Summary
GsonConverter(com.google.gson.Gson gson)
           
 
Method Summary
 Object fromBody(TypedInput body, Type type)
          Convert an HTTP response body to a concrete object of the specified type.
 TypedOutput toBody(Object object)
          Convert and object to an appropriate representation for HTTP transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GsonConverter

public GsonConverter(com.google.gson.Gson gson)
Method Detail

fromBody

public Object fromBody(TypedInput body,
                       Type type)
                throws ConversionException
Description copied from interface: Converter
Convert an HTTP response body to a concrete object of the specified type.

Specified by:
fromBody in interface Converter
Parameters:
body - HTTP response body.
type - Target object type.
Returns:
Instance of type which will be cast by the caller.
Throws:
ConversionException - if conversion was unable to complete. This will trigger a call to Callback.failure(retrofit.RetrofitError) or throw a RetrofitError. The exception message should report all necessary information about its cause as the response body will be set to null.

toBody

public TypedOutput toBody(Object object)
Description copied from interface: Converter
Convert and 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.


Copyright © 2013 Square, Inc.. All Rights Reserved.