-
Notifications
You must be signed in to change notification settings - Fork 660
Open
Description
Describe the bug
When requiring type of Int in a serializable class, type coerce string to int without throwing an error.
To Reproduce
Attach a code snippet or test data if possible.
import kotlinx.serialization.*
import kotlinx.serialization.json.*
@Serializable
class Person(val age: Int)
fun main() {
val obj = Json.decodeFromString<Person>("{\"age\": \"22\"}")
println(obj) // Person(age=22)
}
Expected behavior
EXCEPTION
Environment
- Kotlin version: [e.g. 1.4.0-RC]
- Library version: [e.g. 1.0.0-RC]
- Kotlin platforms: Multiplatform
- Gradle version: [e.g. 6.5.1]
futpib, efemoney, FJEagle, kylichist and Gama11JakeWharton