jonathan
03/10/2018, 8:02 AMJSON.stringify(UserRegistrationRequest("Jonathan"))
Outputs:
{
"user_name": "Jonathan",
"message_name_fojwga$_0": "user_request",
"SENDER_SIDE_x0f2y$_0": {
"name$": "CLIENT",
"ordinal$": 1
}
}
Where UserRegistrationRequest
is:
@Serializable
class UserRegistrationRequest(val user_name: String) : SpyfallMessage {
override val message_name = Companion.message_name // Overrides from interface SpyfallMessage
override val SENDER_SIDE = Side.CLIENT // Overrides from interface SpyfallMessage
companion object {
const val message_name = "user_request"
}
}
message_name
and SENDER_SIDE
as parameters, which then allows me to further deserialize into the various subclasses manually (it's basically a very long when
statement), which means that this name mangling causes deserialization to fail.sandwwraith
03/13/2018, 8:27 AMjonathan
03/13/2018, 8:28 AMmessage_name
and SENDER_SIDE
in every subclass?
That latter workaround doesn't feel in the spirit of OOP...sandwwraith
03/13/2018, 8:45 AM@SerialName
on fields. It will also help you to follow code style conventions for field namesv0.4
and higher?jonathan
03/13/2018, 9:52 AMsandwwraith
03/13/2018, 9:59 AMkotlin.js.JSON
instead kotlinx.serialization.json.JSON
jonathan
03/13/2018, 7:08 PM