Hello, I have a class (external, can't edit source...
# serialization
m
Hello, I have a class (external, can't edit source), that I made a custom serializer for. It works fine like this:
Copy code
@Serializable(with = MySerializer::class) val item: MyClass
But now I need to serialize a list of these items:
Copy code
val items: List<MyClass>
How can I make it work? I cannot use the same annotation, since now it's a
List
.
Copy code
@file:UseSerializers(MySerializer::class)
Annotating the file like this seems to work, but it doesn't feel clean. I'd rather have this specified only for the field, or the containing class at least.
r
Can you put the
@Serializable
on the type? I.e.
List<@Serializable(...) MyClass>
. I don't have an IDE in front of me but I think I've seen that before.