Hello everyone I have a data class ``` import kotl...
# getting-started
n
Hello everyone I have a data class
Copy code
import kotlinx.serialization.Serializable

@Serializable
data class MessageModel (val senderId : String, val channelId : String, val id : String, val contents : String, val date : Long)
And when I do this inside my (this is a multiplatform project) web app
Copy code
console.log(message.date::class.simpleName )
The result is
Double
!! What is happening here? It's causing me runtime errors, as I need a long. This MessageModel I receive from my backend and the value of the date is epoch milis, and the value is
1641905913211
this is interpreted as double. But if I don't use the value of
message.date
and instead just directly input
1641905913211
it works, meaning the value isn't the issue, but for some reason when serializing it becomes a double? Not sure where to ask this, is this Multiplatform issue, Kotlin general issue?
Copy code
const val kotlin = "1.6.10"
    const val kotlinxSerialization = "1.3.2"
e
n
@ephemient thanks, was looking for the issue But wait, this is about rounding, while I am getting an incorrect type serialized. Is this the same issue?
e
yes, long is being rounded into double representation
n
Oh, that's weird. Can't wait for the fix
e
also note that Kotlin/JS uses the JS number type so it doesn't really have a distinction between integer and floating types (it tries, but except for Long, it's a compile time thing only)