When writing a custom serializer for class, do I h...
# serialization
j
When writing a custom serializer for class, do I have to write two identical serializers for nullable and non-nullable? I have a custom serializer
MyClassSerializer : KSerializer<MyClass>
but I'm working with a
Map<String, MyClass?>
and I can't figure out how to manually specify the serializer for the map
h
There's a
KSerializer.nullable
extension that you can use to turn any serializer nullable. So for your example you would want
MapSerializer(String.serializer(), MyClassSerializer.nullable)