Skip to content

Commit 2da8cac

Browse files
committed
Re-work boolean decoder
1 parent 7b353d8 commit 2da8cac

File tree

1 file changed

+6
-1
lines changed
  • firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal

1 file changed

+6
-1
lines changed

firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ private fun decodeShort(value: Any?) = when(value) {
217217
else -> throw SerializationException("Expected $value to be short")
218218
}
219219

220-
private fun decodeBoolean(value: Any?) = value as Boolean
220+
private fun decodeBoolean(value: Any?) = when (value) {
221+
is Boolean -> value
222+
is Number -> value.toInt() != 0
223+
is String -> value.toBoolean()
224+
else -> throw SerializationException("Expected $value to be boolean")
225+
}
221226

222227
private fun decodeChar(value: Any?) = when(value) {
223228
is Number -> value.toChar()

0 commit comments

Comments
 (0)