Skip to content

decodeFromMap() inserts Double into Int variable #1208

Open
@eydunfe

Description

@eydunfe

Describe the bug
Decoding from map allows Double value to be inserted into Int variable.

To Reproduce

@Serializable
data class Foo (
    @SerialName("1")
    val bar: Int
)

fun main() {
    val map = mapOf<String, Any>(Pair("1", 1.23))
    val decodedFoo = Properties.decodeFromMap(Foo.serializer(), map)
    println(decodedFoo) // Foo(bar=1.23)
}

Environment

  • Kotlin version: 1.4.10
  • Library version: 1.0.1
  • Kotlin platforms: JS
  • Gradle version: 6.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions