klaxon
klaxon copied to clipboard
`JsonObject` created by `toJsonObject` from a derived class will not contain members of any superclass.
Superclass members are not included in the JsonObject generated from an object with toJsonObject.
Setup:
class A (val uuid: UUID) {
var name: String = "Something"
}
class B (val rank: Int, uuid: UUID) : A (uuid) {
fun toJson() = Klaxon().toJsonObject(this)
}
B(rank = 4, uuid = UUID.randomUUID()).toJson() // will lack members uuid and name.
Expected: JsonObject contains all members of A and B
Actual: JsonObject contains only member of class B
This is very surprising as it works for the toJsonString
method. There all members are contained.
The reason is possibly the line obj::class.declaredMemberProperties
in class JsonValue
, which could be written as obj::class.memberProperties
instead.
Fixed this in PR #350.