Is it possible to use kotlinx.serialization with t...
# ktor
p
Is it possible to use kotlinx.serialization with the newest version of ktor server? It seems like the documentation is outdated, since I can't find the serialization() function in kotlinx.serialization. https://ktor.io/docs/serialization-converter.html#configuration
j
Copy code
install(ContentNegotiation) {
        json(Json {
            ignoreUnknownKeys = true
            isLenient = true
            prettyPrint = true
        })
    }
This is what I use with ktor 1.4.0
the Json is from the serialization
p
It says: required: JsonObjectBuilder.() -> Unit, Found: Json
I am using ktor 1.4.0 and kotlinx.serialization version 1.0.0-RC2
j
Maybe try serialization 1.0.0-RC
OR ktor 1.4.10 with serialization 1.0.0-RC2
p
is that the version you are using?
j
yes
p
ok i'll try 1.4.10
j
I use 1.4.0 with 1.0.0-RC
I think for 1.4.10 you can use 1.0.0-RC2
but you also have to add "kotlinx-serialization-json"
org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2
p
I don't think version 1.4.10 exists
j
sorry 1.4.1
p
Ah I see
I think it works with 1.4.1
j
which supports kotlin 1.4.10 😄
p
Hmm I am still getting the same error
j
which ktor dependencies do you have?
p
Copy code
val ktorVersion = "1.4.1"

implementation("io.ktor:ktor-server-core:$ktorVersion")
    implementation("io.ktor:ktor-server-netty:$ktorVersion")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2")
j
do you also include
io.ktor:ktor-serialization:1.4.1
p
I didn't, it looks better now
But now I am getting this error: Exception in thread "Thread-0" java.lang.NoSuchMethodError: 'kotlinx.serialization.json.Json kotlinx.serialization.json.JsonKt.Json$default(kotlinx.serialization.json.Json, kotlin.jvm.functions.Function1, int, java.lang.Object)'
At least it compiles now