retrofit.converter
Class GsonConverter
java.lang.Object
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])
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GsonConverter
public GsonConverter(com.google.gson.Gson gson)
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.