Have a custom serializer: ```import kotlinx.serial...
# serialization
a
Have a custom serializer:
Copy code
import kotlinx.serialization.*
import kotlinx.serialization.json.Json

// Uncomment to disable encoding default values
// @Serializable
internal class Action(
    val id: String,
    val routing: String? = null,
)

@Serializer(forClass = Action::class)
object ActionSerializer : KSerializer<Action>

fun main(args: Array<String>) {
    val action = Action(
        id = "1",
    )
    println(Json.encodeToString(ActionSerializer, action))
}
This code produces:
Copy code
{
  "id": "1",
  "routing": null
}
If you uncomment
@Serializable
annotation default values will be ignored. Is this behavior a bug or not?
v
@sandwwraith PTAL
s
I think this is because external serializer(forClass) does not support ignoring default values for now