Kotlin How to reference correctly to the fasterxml class for the jacksonObjectMapper

Viewed 161

Screenshot with the error and my project hierachy dependency snippet of my build.gradle File for the fasterxml class:

dependencies {
    // Json
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1"
    implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: '2.13.0'

}
1 Answers

You're mixing two different libraries, so before all, first decide whether you want to use kotlinx-serialization or jackson.

For kotlinx you don't need the second dependency, but obviously you won't use the jackson mapper in your code but the one provided by kotlinx: https://github.com/Kotlin/kotlinx.serialization#introduction-and-references

For jackson you need to include jackson-databind, not just the kotlin plugin (which just provides some extra kotlin-only features): implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'

Related