crummy
04/28/2020, 11:28 PMedenman
04/28/2020, 11:51 PMcrummy
04/28/2020, 11:57 PM@Serializable(with = LocalDateSerializer::class)
. However, now I'm returning a Map<LocalDate, foo>
and I don't know how to annotate this. Is there a way to register a serializer so that it's always used for a specific class?crummy
04/29/2020, 12:00 AMedenman
04/29/2020, 12:02 AM@Serializable(with = LocalDateSerializer::class)
? it should just work if you put it on LocalDate
afaikcrummy
04/29/2020, 12:05 AMMap<LocalDate, foo>
?edenman
04/29/2020, 12:05 AMLocalDate
class itself, you shouldn’t need any annotation on the Map
crummy
04/29/2020, 12:06 AMedenman
04/29/2020, 12:19 AMcrummy
04/29/2020, 12:30 AMval timesheets: Map<@Serializable(with = LocalDateSerializer::class)LocalDate, DaySummary>
... but it doesn't seem to helpSam Garfinkel
04/29/2020, 3:58 AM@Serializable(with=<Class>)
at each instance of the external class, or use @file:UseSerializers
. I prefer the last solution since it’s a bit more clean imo. Both 2 and 3 only work if the serializer is a singleton or has a no-op constructor, otherwise you’ll need to register a contextual serializer with a SerialModule
Sam Garfinkel
04/29/2020, 4:01 AMSam Garfinkel
04/29/2020, 4:03 AMSam Garfinkel
04/29/2020, 4:04 AMcrummy
04/29/2020, 4:07 AMSam Garfinkel
04/29/2020, 4:09 AMserializer<T>
implementation that I suggested in that issue.