public final class JacksonConverterFactory
extends retrofit2.Converter.Factory
Because Jackson is so flexible in the types it supports, this converter assumes that it can handle all types. If you are mixing JSON serialization with something else (such as protocol buffers), you must add this instance last to allow the other converters a chance to see their types.
Modifier and Type | Method and Description |
---|---|
static JacksonConverterFactory |
create()
Create an instance using a default
ObjectMapper instance for conversion. |
static JacksonConverterFactory |
create(com.fasterxml.jackson.databind.ObjectMapper mapper)
Create an instance using
mapper for conversion. |
static JacksonConverterFactory |
create(com.fasterxml.jackson.databind.ObjectMapper mapper,
okhttp3.MediaType mediaType)
Create an instance using
mapper and mediaType for conversion. |
retrofit2.Converter<?,okhttp3.RequestBody> |
requestBodyConverter(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] parameterAnnotations,
java.lang.annotation.Annotation[] methodAnnotations,
retrofit2.Retrofit retrofit) |
retrofit2.Converter<okhttp3.ResponseBody,?> |
responseBodyConverter(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] annotations,
retrofit2.Retrofit retrofit) |
JacksonConverterFactory |
withStreaming()
Return a new factory which streams serialization of request messages to bytes on the HTTP thread
This is either the calling thread for
Call.execute() , or one of OkHttp's background
threads for Call.enqueue(retrofit2.Callback<T>) . |
public static JacksonConverterFactory create()
ObjectMapper
instance for conversion.public static JacksonConverterFactory create(com.fasterxml.jackson.databind.ObjectMapper mapper)
mapper
for conversion.public static JacksonConverterFactory create(com.fasterxml.jackson.databind.ObjectMapper mapper, okhttp3.MediaType mediaType)
mapper
and mediaType
for conversion.public JacksonConverterFactory withStreaming()
Call.execute()
, or one of OkHttp's background
threads for Call.enqueue(retrofit2.Callback<T>)
. Response bytes are always converted to message instances on
one of OkHttp's background threads.public retrofit2.Converter<okhttp3.ResponseBody,?> responseBodyConverter(java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, retrofit2.Retrofit retrofit)
responseBodyConverter
in class retrofit2.Converter.Factory
public retrofit2.Converter<?,okhttp3.RequestBody> requestBodyConverter(java.lang.reflect.Type type, java.lang.annotation.Annotation[] parameterAnnotations, java.lang.annotation.Annotation[] methodAnnotations, retrofit2.Retrofit retrofit)
requestBodyConverter
in class retrofit2.Converter.Factory