Hey I can't figure out how to serilize this in kot...
# serialization
j
Hey I can't figure out how to serilize this in kotlin. Preferably with kotlinx serilizastion. Here a typescript reference. Can someone guide me to an implementation?
Copy code
function handleData(data: Record<string, unknown>) {
const bar: Record<string,unknown> = {
foo: "hi",
props: {...this.otherData, ...data}
}
return bar
}
This should end up as
Copy code
{ 
foo: "hi",
props: {
  uno: 1
  dos: "two"
 }
}
j
data class Some(val foo: String, val props: Map<String, Any>)
or creating a sealed class for props so you can type safe it
well... props is a list or just an object? in if it is just an object then
data class Some(val foo: String, val props: Props)
data class Props(val uno: Int, val dos: String)
j
props is an object which structure changes depending on the use case. Last time I tried to serialise
any
, kotlin complained but I am trying it tomorrow. Than you so much! @Javier
I can implement it as list i guess
j
sealed class should be valid if there is a limit of structures