You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Long values are not validated to be actual longs when parsed from JsonObject
To Reproduce
import kotlinx.serialization.json.*
import kotlinx.serialization.*
@Serializable
data class A(val a: Long)
fun main() {
val str = """{"a":"12:34:45"}"""
println(Json.decodeFromJsonElement<A>(Json.decodeFromString<JsonObject>(str)))
println(Json.decodeFromString<A>(str))
}
Expected behavior
Both crash with SerializationException.
Actually first prints A(a=12), while second one crashes. Btw, the error message in the second one is really misleading.
Environment
Kotlin version: 2.0.20
Library version: 1.7.3
Kotlin platforms: JVM
The text was updated successfully, but these errors were encountered:
Content must be consumed fully, with no leftovers after number.
Also simplify try/catching logic — JsonLiteral.long should throw NumberFormatException, while decoding from JsonElement should throw JsonDecodingException
Fixes#2849
…ons (#2852)
Content must be consumed fully, with no leftovers after number.
Also simplify try/catching logic — JsonLiteral.long should throw NumberFormatException, while decoding from JsonElement should throw JsonDecodingException
Fixes#2849
Describe the bug
Long values are not validated to be actual longs when parsed from JsonObject
To Reproduce
Expected behavior
Both crash with SerializationException.
Actually first prints
A(a=12)
, while second one crashes. Btw, the error message in the second one is really misleading.Environment
The text was updated successfully, but these errors were encountered: