I have a problem where I have this Health data cla...
# serialization
j
I have a problem where I have this Health data class that has a generic type parameter.
T
can either be
Nothing
or something user-defined (that also has a
@Serializable
annotation). Whenever I try to serialize it I get an error:
Copy code
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.