Christian Sousa
03/18/2020, 3:42 PMLastExceed
03/18/2020, 3:43 PMChristian Sousa
03/18/2020, 3:53 PMLastExceed
03/18/2020, 3:54 PMChristian Sousa
03/18/2020, 4:04 PMdata class StatusObject (
val event: String
)
then I have
var myMutableMap: MutableMap<String, Any?> = mutableMapOf("event" to "default")
After that I receive an array of objects and will map through them to add them to myMutableMap
receivedArrayWithObjects.forEach {
myMutableMap[it.header.name] = it.status.name
}
But in the end, I need to return a StatusObject
I’m having this problem because I’m bringing code from Javascript to KotlinRobert Jaros
03/18/2020, 4:22 PM@Serializable
you can use kotlinx.serialization
library for this.Christian Sousa
03/18/2020, 4:23 PMRobert Jaros
03/18/2020, 4:24 PMRobert Jaros
03/18/2020, 4:24 PMMapper
class was renamed to Properties
in serialization 0.20.0Christian Sousa
03/18/2020, 4:24 PMRobert Jaros
03/18/2020, 4:26 PMMichael de Kaste
03/19/2020, 7:57 AMclass StatusObject(mapInput: MutableMap<String, Any?>) {
val event: String by mapInput
var otherVariable: YourComplexType? by mapInput
}
advantage of this method is that you can keep adding to the map after creation and the corresponding variables will update accordingly.