v79
12/04/2021, 4:37 PM@Serializable
class GameState {
var playerName = "Dougie McDougal"
@Transient
var saveFileName = "save1"
suspend fun save() {
println("Saving game state $saveFileName.gs.json")
val gameStateJson = Json.encodeToString(this@GameState)
val saveFile = applicationVfs["saves/$saveFileName.gs.json"]
saveFile.write(gameStateJson.toByteArray())
}
}
The serialized output is just {}
- empty. playerName
is not being serialised. Any thoughts?v79
12/04/2021, 4:43 PMplayerName
should be serialized.v79
12/04/2021, 4:56 PM@Required
annotation has solved this, though the documentation doesn't make that explicitly needed.Dariusz Kuc
12/05/2021, 4:27 PM