9 months ago
    I'm hitting an odd issue where a class can't seem to serialize itself, or at least it's not serializing its backing fields. It's a small class:
    class GameState {
        var playerName = "Dougie McDougal"
        var saveFileName = "save1"
        suspend fun save() {
            println("Saving game state $")
            val gameStateJson = Json.encodeToString(this@GameState)
            val saveFile = applicationVfs["saves/$"]
    The serialized output is just
    - empty.
    is not being serialised. Any thoughts?
    Adding the
    annotation has solved this, though the documentation doesn't make that explicitly needed.
    Dariusz Kuc

    Dariusz Kuc

    9 months ago
    I believe default values are omitted by default - its configurable by a flag OR by explicitly marking field required so it will always be present