Is there any easy way to (de)serialize purely thro...
# serialization
m
Is there any easy way to (de)serialize purely through an
interface
? That is, without adding any support for serialization to the implementing
class
, and when deserializing have the compiler generate an
object
that implements the
interface
.
Copy code
@Serializable
interface Foo {
	val bar1: String
	val bar2: Int
}
Should serialize too
{"bar1":"…","bar2":…}
independent of the implementing
class
.
{"bar1":"abc","bar2":42}
should deserialize to
object : Foo { override val bar1 = "abc"; override val bar2 = 42 }
.
n
you could probably make a compiler plugin that processes interfaces with
@SerializableInterface
annotation and generates a
@Serlaizable
data class for them as well as extensions for
serializer()
and such
m
Seems reasonable if there is no standard way 👍