I am having an issue with kotlinx.serialization 1....
# ktor
p
I am having an issue with kotlinx.serialization 1.0.0-RC2. This is my build.gradle.kts:
Copy code
plugins {
    kotlin("jvm") version "1.4.10"
    kotlin("plugin.serialization") version "1.4.10"
    java
    `maven-publish`
}

group = "com.test"
version = "1.0-beta"

val ktorVersion = "1.4.1"
val logbackVersion = "1.2.3"

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
    implementation("io.ktor:ktor-server-core:$ktorVersion")
    implementation("io.ktor:ktor-server-netty:$ktorVersion")
    implementation("io.ktor:ktor-serialization:$ktorVersion")
    implementation("ch.qos.logback:logback-classic:$logbackVersion")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2")
}
And this is my configuration:
Copy code
install(ContentNegotiation) {
                json(Json {
                    isLenient = true
                })
            }

            install(StatusPages) {
                exception<Throwable> { e ->
                    call.respond(HttpStatusCode.InternalServerError, mapOf("OK" to false, "error" to e.message))
                }
            }
This compiles, but when I try to start the server I get 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 io.ktor.serialization.JsonSupportKt.<clinit>(JsonSupport.kt:29)
Is this a common error? What should I change?
e
@cy, could you take a look?
j
can it be that it cannot serialize the map<String, String> ?
did you try to try to print out a @Serializable object?
Copy code
@Serializable
data class InternalServerError(OK: Boolean, error: String)
p
It works if I use the jackson implementation
And leave everything else the same