Maybe a dumb question. I've got a `data class MyCl...
# serialization
a
Maybe a dumb question. I've got a
data class MyClass(val foo: String)
that I can conveniently retrive from dynamic JS by using
DynamicObjectParser().parse(js("""{ foo: "bar" }"""), MyClass.serializer())
. Is there a way that I can do the opposite, going from an instance of
MyClass
to a dynamic type JS blob
{ foo: "bar" }
? The goal is to be able to call into the Kotlin/JS artifact from real-JS and be able to predictably interact with the output without having extra bits of data on it. I can get to a
Map<String, Any?>
using
Mapper.mapNullable(MyClass.serializer(), instance)
, but I'm not sure if there's a step that I'm missing after that...
f
It sounds like you want a string? How about
stringify
a
Nope; I actually want a JavaScript object. The idea is that I want to use this data from pure JS land, and would like the fields and values on the JS object to be exactly as given, without any mangling or extra type info