Thread
#serialization
    r

    Rainer Schlonvoigt

    1 year ago
    Probably a stupid question, but googling doesn’t get me anywhere 😕 Can i easily use
    @Serializable(with=...)
    on a Set of a custom class? More specifically, my scenario looks like this:
    @Serializable
    data class MyClass(
        @Serializable(with=???)
        val mySet: Set<UUID>
    )
    where UUID is from java.util so i can’t annotate it
    i did write a KSerializer for UUID, but is there a cheap way to make it work with the Set?
    d

    diesieben07

    1 year ago
    I think
    @file:UseSerializers(YourUUIDSerializer::class)
    would be easiest
    r

    Rainer Schlonvoigt

    1 year ago
    oh, didn’t know that one, yet
    thank you, will give it a try! 🙂
    e

    ephemient

    1 year ago
    val mySet: Set<@Serializable(with = MyUuidSerializer::class) UUID>
    should work too, but
    @file:UseSerializers()
    is easier if you have more than one instance in the file
    r

    Rainer Schlonvoigt

    1 year ago
    it works! thank you guys