https://kotlinlang.org logo
#ktor
Title
# ktor
a

aleksey.tomin

10/12/2020, 7:53 AM
How can I use
kotlin.serialization
in native (ktor client + curl)? Way from https://ktor.io/docs/serialization-converter.html
install(ContentNegotiation) { serialization() }
doesn’t work -
ContentNegotiation
exists only for jvm.
j

John O'Reilly

10/12/2020, 7:58 AM
I may be misunderstanding question but am using
JsonFeature
for this
Copy code
HttpClient() {
            install(JsonFeature) {
                serializer = KotlinxSerializer(nonStrictJson)
            }
        }
m

manlan

10/12/2020, 8:00 AM
@aleksey.tomin Hi, for me, it isn't even working on the JVM.
serialization()
is not being resolved. I have these in my build.gradle.kts:
Copy code
plugins {
    application
    kotlin("jvm") version "1.4.10"
    kotlin("plugin.serialization") version "1.4.10"
}
dependencies {   implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
}
g

gildor

10/12/2020, 12:10 PM
You also need ktor serialization dependencies https://ktor.io/docs/json-feature.html#kotlinx-serialization
a

aleksey.tomin

10/12/2020, 12:13 PM
@John O'Reilly Thank you, it works fine!
👍 1