Hi all, I’m trying to serialise and deserialise ev...
# serialization
s
Hi all, I’m trying to serialise and deserialise events with Kotlin serialization and reflection but I don’t understand how deserialise them.
Copy code
//recordedEvent is a class with the json and the original event class name

val eventType = recordedEvent.eventType // com.xyz.events.UserCreatedEvent
val jsonEvent = recordedEvent.eventData.decodeToString() // {"messageId": "8775b466-9f2f-4604-afe6-71914d95381f","aggregateId":{"value": "e755ed27-1fac-4fce-868c-61e941974316"}, "name": "name_1"}

val event = Json.decodeFromString<eventType>(jsonEvent) //<-- ??
How can I cast my event to EventType? Any idea? Thanks