I want to serialize a set of IP addresses. I have ...
# serialization
b
I want to serialize a set of IP addresses. I have created an InetAddressSerializer, but how do I apply it to a set using annotations? I can't use
(..).set
in an annotiation.
Copy code
@Serializable
data class SessionState(
        @Serializable(with = InstantSerializer::class)
        val start: Instant,
        val ips: Set<InetAddress>?
)
Ok, I've solved it like this now:
Copy code
object InetAddressSetSerializer : KSerializer<Set<InetAddress>> by InetAddressSerializer.set

@Serializable(with = InetAddressSetSerializer::class)
but it doesn't seem desirable to me to do it like this every time a collection needs to be serialized