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
Copy file name to clipboardExpand all lines: formats/json/jsMain/src/kotlinx/serialization/json/internal/DynamicDecoders.kt
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,12 @@ private open class DynamicInput(
134
134
overridefundecodeTaggedChar(tag:String): Char {
135
135
returnwhen (val value = getByTag(tag)) {
136
136
isString->if (value.length ==1) value[0] elsethrowSerializationException("$value can't be represented as Char")
137
-
isNumber-> value.toChar()
137
+
isNumber-> {
138
+
val num = value as?Double?:throwSerializationException("$value is not a Number")
139
+
val codePoint = toJavascriptLong(num)
140
+
if (codePoint <0|| codePoint >Char.MAX_VALUE.code) throwSerializationException("$value can't be represented as Char because it's not in bounds of Char.MIN_VALUE..Char.MAX_VALUE")
141
+
codePoint.toInt().toChar()
142
+
}
138
143
else->throwSerializationException("$value can't be represented as Char")
0 commit comments