【发布时间】:2021-03-01 19:05:42
【问题描述】:
我正在尝试使用 Ktor 和 Jackson 配置 jackson-modules-java8,但无济于事。
模块添加到gradle.build
dependencies {
...
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0-rc2'
...
}
根据 Jackson 文档,我应该这样做:
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?
}
}
【问题讨论】: