-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Converters
Maksim Kovalev edited this page Jun 25, 2024
·
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
-
kotlinx.serialization -
com.squareup.retrofit2:converter-kotlinx-serialization
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:
-
MessagePack -
org.komamitsu:retrofit-converter-msgpack:1.1.0
-
LoganSquare -
com.github.aurae.retrofit2:converter-logansquare
-
FastJson -
com.github.ZYRzyr:FastJsonConverter
-
FastJson -
org.ligboy.retrofit2:converter-fastjson
ororg.ligboy.retrofit2:converter-fastjson-android
-
Thrifty -
co.infinum:retrofit-converter-thrifty
-
jspoon (HTML)-
pl.droidsonroids.retrofit2:converter-jspoon
-
Fruit -
me.ghui:fruit-converter-retrofit
-
JakartaEE JsonB -
io.github.cchacin:jsonb-retrofit-converter