Emre
06/25/2024, 7:29 PM@serializable
or having some annotation?Ben Woodworth
06/26/2024, 1:42 AMJson.encodeToString(value)
would've use it. Technically though anything could be serializable depending on the Json instance's serializersModule, so it's a little fuzzy what actually counts as serializable, and is also out of reach from the type system because it's configurable.
In the past (especially for testing) I've used a simple SerializableValue class, passing around the value bundled with its serializer. It can be a bit obtrusive though depending on what you're doing.
data class SerializableValue<T>(
val serializer: KSerializer<T>,
val value: T
)
Emre
06/26/2024, 2:28 AM