James
03/05/2025, 12:46 PMT
can either be Nothing
or something user-defined (that also has a @Serializable
annotation).
Whenever I try to serialize it I get an error:
kotlinx.serialization.SerializationException: Serializer for class 'Health' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
All my data classes are defined with Serializable, so I'm unsure of how to go forward with this. I was thinking about writing a custom serializer that implements KSerializer. But I'm not entirely sure where to start as I haven't really looked into writing serializers before. I want to avoid doing anything JSON specific, as the type should work for other formats than JSON as well.
Any advice appreciated.