jackson3/README.md
This module adds support for encoding and decoding JSON via Jackson 3.
Note: Jackson 3 requires Java 17 or higher.
Add Jackson3Codec to your Feign.Builder like so:
GitHub github = Feign.builder()
.codec(new Jackson3Codec())
.target(GitHub.class, "https://api.github.com");
If you want to customize the JsonMapper that is used, provide it to the Jackson3Codec:
JsonMapper mapper = JsonMapper.builder()
.changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL))
.enable(SerializationFeature.INDENT_OUTPUT)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
GitHub github = Feign.builder()
.codec(new Jackson3Codec(mapper))
.target(GitHub.class, "https://api.github.com");
You can also configure the encoder and decoder separately:
GitHub github = Feign.builder()
.encoder(new Jackson3Encoder())
.decoder(new Jackson3Decoder())
.target(GitHub.class, "https://api.github.com");
The main differences are:
com.fasterxml.jackson → tools.jackson (except for com.fasterxml.jackson.annotation)com.fasterxml.jackson.core → tools.jackson.coreObjectMapper is immutable and must be configured via JsonMapper.builder()