我正在尝试jackson-modules-java8
使用 Ktor 和 Jackson 进行配置,但无济于事。
该模块被添加到gradle.build
dependencies {
...
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0-rc2'
...
}
根据杰克逊文档,我应该这样做:
ObjectMapper mapper = JsonMapper.builder()
.addModule(new JavaTimeModule())
.build();
但在 Ktor 我只能这样做:
install(ContentNegotiation) {
jackson {
// `this` is the ObjectMapper
this.enable(SerializationFeature.INDENT_OUTPUT)
// what to do here?
}
}