Is there a recommended approach to serialize/deser...
# serialization
r
Is there a recommended approach to serialize/deserialize inline value classes that are not based of a primitive? Example:
Copy code
@JvmInline
value class UserId(value: UUID)
It serializes to a nice UUID string, but turning that back into a class seems to involve substantial boiler plate using Jackson or kotlin serialization libs
e
There's a UUID serializer in https://github.com/Kantis/ks3 if you want to give it a try. I notice that it's missing a typealias but you could use it either by adding
Copy code
typealias UuidAsString = @Serializable(with = UuidSerializer::class) UUID

@JvmInline
value class UserId(value: UuidAsString)
(the typealias should be added to the lib, at which point you'd just need to import it instead) Or just specifying it directly: (IIRC)
Copy code
@JvmInline
value class UserId(@Serializable(with = UuidSerializer::class) value: UUID)
r
thanks i will take a look