Could I somehow use JsonTransformingSerializer instead for this data class so its simpler?
Copy code
@Serializable
internal data class ElementRenderer<T>(private val newElement: NewElement<T>) {
val model = newElement.type.componentType.model
@Serializable
data class NewElement<T>(val type: Type<T>)
@Serializable
data class Type<T>(val componentType: ComponentType<T>)
@Serializable
data class ComponentType<T>(val model: T)
}
Oh. I was thinking JsonTransformingSerializer since its simpler to implement and for Json. with kserializer I'd have to add some extra stuff like serialize method which I will not be using in my project and having to cast the decoder to use it as Json
zt
12/21/2022, 12:03 AM
Could I implement KSerializer without implementing the serialization method?
e
ephemient
12/21/2022, 12:24 AM
you can implement only
DeserializationStrategy<T>
and pass that to
decodeFromString
ephemient
12/21/2022, 12:25 AM
most APIs are set up assuming both serialize and deserialize though