When working with custom serializers, do you reall...
# serialization
g
When working with custom serializers, do you really need to provide separate ones for the type itself and for the collection of this type? ex:
Copy code
@Serializable(with = FooSerializer::class)
 val names: List<Foo>
Works only if I define
FooSerializer: KSerializer<List<Foo>>
. I'm wondering if I can define only
FooSerializer: KSerializer<Foo>
and let the kotlin to deal with collections.
👍 1
m
I will try this solution, thanks. I have some data classes annotated that have collection properties as in your example.
g
what do you mean solution, I don't like it, there must be a better way simple smile
m
Hahaha you are right, it would be great use the annotations. But in fact, I ran a quick test implementing the serializers separated and works like a charm, thanks so much.