Skip to content

Commit

Permalink
Jankson serializer and deserializer don't ignore booleans anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneParadox committed Dec 12, 2019
1 parent 4734590 commit d08d4fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class JanksonConfigDeserializer: ConfigDeserializer<JsonElement> {
override fun <R: Any> tryDeserialize(e: JsonElement, rClass: KClass<R>): R? {
if (e is JsonPrimitive) {
val any = when (val value = e.value) {
is Char, is Double, is Long -> value
is Char, is Double, is Long, is Boolean -> value
is Byte, is Short, is Int -> (value as Number).toLong()
is Float -> value.toDouble()
is String -> if (rClass == Identifier::class) Identifier.tryParse(value) else value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class JanksonConfigSerializer: ConfigSerializer<JsonElement> {

override fun trySerialize(value: Any): JsonElement? {
return when (value) {
is String, is Char, is Byte, is Short, is Int, is Long, is Float, is Double -> JsonPrimitive(value)
is String, is Char, is Byte, is Short, is Int, is Long, is Float, is Double, is Boolean -> JsonPrimitive(value)
is Identifier -> JsonPrimitive(value.toString())
else -> null
}
Expand Down

0 comments on commit d08d4fb

Please sign in to comment.