v79
01/21/2025, 9:42 PMv79
01/21/2025, 9:49 PMDaniel Pitts
01/22/2025, 12:56 AMephemient
01/22/2025, 5:23 AMephemient
01/22/2025, 5:24 AMfun serializer()
which the plugin won't overwriteephemient
01/22/2025, 5:25 AMv79
01/22/2025, 6:03 AMv79
01/22/2025, 6:11 AM@Serializable
class Company(var name: String, var sciences: MutableMap<Science, Float>) {
companion object {
val VOID: Company = Company("VOID", mutableMapOf())
}
}
@Serializable
class GameState : Node() {
var year: Int = 1980
var company: Company = Company("My company", mutableMapOf())
var country: Country? = null
}
This serializes correctly. But:
@Serializable
class Company(var name: String, var sciences: MutableMap<Science, Float>) {
companion object {
val VOID: Company = Company("VOID", mutableMapOf())
}
}
@Serializable
class GameState : Node() {
var year: Int = 1980
var company: Company = Company.VOID
var country: Country? = null
}
When this serializes, there is no Company in the json output.
In both cases, the value of company will have changed before save() is called, so I'd never expect to see "VOID" in the output but I would expect to see something.
Typical correct output is:
{
"year": 1965,
"company": {
"name": "EuroStellar Space Corp,
"sciences": {
"PHYSICS": 9.359396,
"ASTRONOMY": 3.01254,
"BIOCHEMISTRY": 4.3982563,
"GEOLOGY": 9.570941,
"MATHEMATICS": 2.9410443,
"PSYCHOLOGY": 2.9936967,
"UNKNOWN": 7.0150113
}
},
"country": {
"id": 2,
"name": "North America",
"colour": {
"r": 1.0,
"a": 1.0,
"r8": 255,
"a8": 255,
"s": 1.0,
"v": 1.0
}
}
}
ephemient
01/22/2025, 6:15 AMdata class
and you don't override equals
, so
Company.VOID == Company.VOID
Company("My company", mutableMapOf()) != Company("My company", mutableMapOf())
so one of them is ==
to the default and the other is notephemient
01/22/2025, 6:17 AMv79
01/22/2025, 6:24 AM