(I know it's more a Jackson than a Kotlin question...
# getting-started
n
(I know it's more a Jackson than a Kotlin question, but I hope someone might have an answer anyway). I have a line `val jackson: YAMLMapper = YAMLMapper.builder().addModule(KotlinModule()).build()`in my code to create a Jackson YAML mapper with Kotlin extensions. This tells me "Kotlin: 'constructor KotlinModule(Int = ..., Boolean = ..., Boolean = ..., Boolean = ..., SingletonSupport = ..., Boolean = ...)' is deprecated. Use KotlinModule.Builder instead of named constructor parameters". Does that really mean I should use `val jackson: YAMLMapper = YAMLMapper.builder().addModule(KotlinModule.Builder().build()).build()`instead? That's an awful amount of build...
e
use
kotlinModule { }
n
and how do I get the YAML mapper into that?
m
An alternative way is to use:
Copy code
val jackson = ObjectMapper(YAMLFactory()).registerKotlinModule()
n
that will result in an
ObjectMapper
and not a
YAMLMapper
but should be ok for me because I don't think I need any YAMLMapper-specific APIs.
m
Yeah, in most cases you shouldn't
e
kotlinModule { ... }
replaces
KotlinModule.Builder(). ... .build()
, so you should see how to use that with
YAMLMapper.builder()
n
right. So I have 2 options which seems equally good:
ObjectMapper(YAMLFactory()).registerKotlinModule()
and
YAMLMapper.builder().addModule(kotlinModule()).build()
. Thanks for your help!
650 Views