encodeDefaults

Specifies whether default values of Kotlin properties should be encoded. false by default.

Example:

@Serializable
class Project(val name: String, val language: String = "kotlin")

// Prints {"name":"test-project"}
println(Json.encodeToString(Project("test-project")))

// Prints {"name":"test-project","language":"kotlin"}
val withDefaults = Json { encodeDefaults = true }
println(withDefaults.encodeToString(Project("test-project")))

This option does not affect decoding.