Trying to transform a `class Sms(val phone: String, val code: String)` into `{"sms":{"phone":"123012...
n
Trying to transform a
class Sms(val phone: String, val code: String)
into
{"sms":{"phone":"1230129","code":"23984"}}
... I know that I can add
SmsWrapper(val sms: Sms)
and require people to use it, but I'd like to use a custom serializer instead. Is there any example to do such thing? I see many examples where structures are flattened (e.g. you remove a
{}
container), but couldn't find one where you do the opposite (nest data in a new
{}
).
b
You can simplify it a bunch if you only need it for the Sms class. Combine the Serializer and Deserializer classes into one KSerializer<Sms>, remove nbtFile, and replace nbtFile.tagName with
"sms"