I want to use Kotlin data class in java with jacks...
# jackson-kotlin
m
I want to use Kotlin data class in java with jackson serializer. If I want to use koltin data class from Java then I must set default parameters to create a default constructor for jackson serializer. Is there any other way?
e
Try using the Jackson Kotlin Module. It adds support for this. https://github.com/FasterXML/jackson-module-kotlin
m
@Evan R. thank you for response! So I have to add it to the Java project, am I right?
Does it require any setup in such case? or just add it instead of jackson and that is it?
e
It’s a module that plugs into jackson. Instructions are on the readme of the repo I linked you to, but TL;DR is that you apply the Kotlin Module to the Object Mapper wherever you have it defined, or in Kotlin you can just call the extension function
.registerKotlinModule()
on the ObjectMapper
m
@Evan R. thank you!
👍 1
275 Views