Hello! I have some weird error trying to run a Kto...
# serialization
n
Hello! I have some weird error trying to run a Ktor call with a body:
Copy code
W/System.err: kotlinx.serialization.SerializationException: Serializer for class 'Companion' is not found.
    Mark the class as @Serializable or provide the serializer explicitly.
The place I am trying to use:
Copy code
try {
            api.createAccount(Account(handle = "some", displayname = "Some name"))
        } catch (e: Exception) {
            e.printStackTrace()
        }
And the class itself:
Copy code
import kotlinx.serialization.Serializable

@Serializable
data class Account(val handle: String, val displayname: String)
Ktor's HttpClient config contains:
Copy code
install(JsonFeature) {
            serializer = KotlinxSerializer(Json {
                ignoreUnknownKeys = true
                encodeDefaults = true
                useAlternativeNames = false
            })
        }
In my build.gradle.kts of the module I have:
Copy code
plugins {
    kotlin("multiplatform")
    kotlin("plugin.serialization")
    id("com.squareup.sqldelight")
    id("com.android.library")
}

kotlin {
    ...
    sourceSets {

        val serializationVersion = "1.2.2"
        val ktorVersion = "1.6.2"


        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")
                implementation("io.ktor:ktor-client-logging:$ktorVersion")
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-ios:$ktorVersion")
            }
        }
    }
}
What am I doing wrong?
The problem was not at serializing
Account
class but on deserializing the response, so the issue is closed