Is there a straight forward way to create a (de)se...
# serialization
n
Is there a straight forward way to create a (de)serializer from a Lombok generated Java class? In particular I need to serialize these class to and from Json for use in AWS.
Using the following
Copy code
@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = APIGatewayV2HTTPEvent::class)
object APIGatewayV2HTTPEventSerializer : KSerializer<APIGatewayV2HTTPEvent>
results in
Copy code
org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass@5a5ecff is expected to have a primary constructor
p
The only way to do it would be to use reflection (either at compile time (kapt/kapt2?), or at runtime) to generate a custom serializer. The problem is that the compiler needs to see the source code (in Kotlin) of the actual class to be able to generate a serializer (in addition if there is a non-empty parent it must be serializable itselve).
n
I thought KSP worked with both Java and Kotlin? Are there any plans to add this functionality to kotlinx.serialization project or is this likely to only ever be a 3rd party solution?
ok looks like it is never going to happen: https://github.com/Kotlin/kotlinx.serialization/issues/1687