Skip to content
ghui edited this page Oct 18, 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 delegate 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 - com.github.ZYRzyr:FastJsonConverter
  • FastJson - org.ligboy.retrofit2:converter-fastjson or org.ligboy.retrofit2:converter-fastjson-android
  • Thrifty - co.infinum:retrofit-converter-thrifty
  • jspoon (HTML)- pl.droidsonroids.retrofit2:converter-jspoon
  • Fruit - me.ghui:fruit-converter-retrofit
Clone this wiki locally