Skip to content
Jake Wharton edited this page May 15, 2017 · 20 revisions

Retrofit is pluggable allowing different serialization formats and their libraries to be used for converting Java types to their HTTP representation and parsing HTTP entities back into Java types.

These are called converters, and Retrofit includes a few first-party modules for popular frameworks:

  • Gson - com.squareup.retrofit2:converter-gson
  • Jackson - com.squareup.retrofit2:converter-jackson
  • Moshi - com.squareup.retrofit2:converter-moshi
  • Protobuf - com.squareup.retrofit2:converter-protobuf
  • Wire - com.squareup.retrofit2:converter-wire
  • Simple Framework - com.squareup.retrofit2:converter-simplexml
  • Scalars - com.squareup.retrofit2:converter-scalars

Two delegating converters are also provided:

  • Guava's Optional<T> - com.squareup.retrofit2:converter-guava
  • Java 8's Optional<T> - com.squareup.retrofit2:converter-java8

These differ from the normal converters in that they don't actually convert bytes to object. Instead, they delgate to a normal converter for that and then wrap the optionally-nullable resulting value into an Optional.

Various third-party converters have been created by the community for other libraries and serialization formats:

  • LoganSquare - com.github.aurae.retrofit2:converter-logansquare
  • FastJson - org.ligboy.retrofit2:converter-fastjson or org.ligboy.retrofit2:converter-fastjson-android
Clone this wiki locally