Hi!
I'm trying to construct a Js object in Kotlin. As I understand, I can do the following when I have a list of variables, and I want to put them into a Js object.
val myObject: dynamic = js("{}")
params.forEach { param ->
myObject[param.key] = param.value
}
But can I somehow convert this class
class MyClass(
val variable1: String,
val variable2: String,
val variable3: String
)
into a Js object, like this?
{
variable1: "",
variable2: "",
variable3: ""
}
If i try
myObject[key] = Json.encodeToString(MyClass(" ", " ", " "))
it will be a simple string instead of a js object.