Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 9941d5f

Browse files
committed
Fix class cast exception with long/float
1 parent 8b6139e commit 9941d5f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/kotlin/org/sandboxpowered/fabric/util/PolyglotUtil.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ fun Value.toJSON(): JsonElement = when {
2222
}
2323
isString -> JsonPrimitive(asString())
2424
isBoolean -> JsonPrimitive(asBoolean())
25-
isNumber -> JsonPrimitive(asInt())
25+
isNumber -> when {
26+
fitsInInt() -> JsonPrimitive(asInt())
27+
fitsInLong() -> JsonPrimitive(asLong())
28+
fitsInFloat() -> JsonPrimitive(asFloat())
29+
else -> JsonNull.INSTANCE
30+
}
2631
else -> JsonNull.INSTANCE
2732
}

0 commit comments

Comments
 (0)