im receiving an object from "real" js code which h...
# javascript
t
im receiving an object from "real" js code which has all the properties like a data class i defined, but is not an instance of that class. is there an easy way to convert it into an object of my class in that case?
r
Consider annotating your data class with
@Serializable
a
I've been dealing with this by adding extension functions on
Json
to map it into each of my data classes... but that's definitely not the optimal approach
t
@Robert Jaros thanks for yourinput - i tried this approach and found at least on bug in kotlinx.serialization (and filed) it. so whule didn;t work out (yet), at least i could help improving the library 😄
@ankushg not the best approach, yes, but i will do something like that, until the bug in the library is fixed. thank you, too 😄