Andrey Tabakov

    Andrey Tabakov

    3 months ago
    Why variable that starts with
    is
    is omitted while serialization? I have data class
    @Serializable
    public data class Config(
        val isVariable: String,
        val anotherVariable: String
    )
    
    Config("omit", "value")
    Output will be:
    {anotherVariable:"value"}
    P.S. isVariable should be boolean, I know, anyway it should be a String in my case
    e

    ephemient

    3 months ago
    that example works fine for me, producing
    {"isVariable":"omit","anotherVariable":"value"}
    (Kotlin 1.7.0, kotlinx.serialization 1.3.3). do you have a default vaule of
    isVariable
    ?
    Andrey Tabakov

    Andrey Tabakov

    3 months ago
    Kotlin 1.7.0, kotlinx.serialization 1.3.3 - same config no default value
    hm, seems problem with content negotiation in ktor
    install(ContentNegotiation) {
        json(
            Json {
                ignoreUnknownKeys = true
                isLenient = true
            }
        )
    }
    serialization (encodeToString) works fine