Okey, one more question. I am trying to convert ja...
# javascript
a
Okey, one more question. I am trying to convert javascript object to kotlin class. I.e.
Copy code
data class Book(val bookId: Int)
val obj = js("{ bookId: 10 }")
val book = obj as Book
Last line fails with
ClassCastException
(of course). What is the correct way to do it?
☝️ 1
g
You can use kotlinx.serialization #serialization
b
also, depending on your requirements, you can describe it as
Copy code
external interface Book {
  val bookId: Int
}