Jackson
The jackson extension package for Fuel.
Installation
You can download and install fuel-jackson with Maven and Gradle. The jackson package has the following dependencies:
Jackson: 2.9.8
implementation 'com.github.kittinunf.fuel:fuel:<latest-version>'
implementation 'com.github.kittinunf.fuel:fuel-jackson:<latest-version>'Usage
The Fuel-Jackson module provides a built in support for Jackson serialization and deserialization.
Serialization
The serialization is done by adding the objectBody extension function into Fuel Request interface.
By default, the objectBody call will use the Charsets.UTF-8 charset and the defaultMapper property defined in FuelJackson.kt.
data class FakeObject(val foo: String = "foo")
Fuel.post("/fooBar")
.objectBody(FakeObject())Alternatively, you can provide a custom charset as a parameter to it.
You can also provide your own ObjectMapper as a parameter.
Deserialization
The deserialization is done by adding the responseObject extension function into Fuel Request interface.
By default, the responseObject call will use the defaultMapper property defined in FuelJackson.kt.
Alternatively, you can provide your own ObjectMapper as a parameter to it.
Also, the responseObject overloads allows you to pass Response Handlers as lambda functions
or ResponseHandler<T> instances.
Both overloads allows you to provide custom ObjectMapper if needed.
Last updated
Was this helpful?