From: Alexis Laferrière Date: Thu, 27 Jul 2017 16:05:13 +0000 (-0400) Subject: json: deser. chars serialized as strings and bytes as ints X-Git-Url: http://nitlanguage.org json: deser. chars serialized as strings and bytes as ints Signed-off-by: Alexis Laferrière --- diff --git a/lib/json/serialization_read.nit b/lib/json/serialization_read.nit index 3c8b170..13a48d1 100644 --- a/lib/json/serialization_read.nit +++ b/lib/json/serialization_read.nit @@ -326,6 +326,16 @@ class JsonDeserializer return array end + if object isa String and object.length == 1 and static_type == "Char" then + # Char serialized as a JSON string + return object.chars.first + end + + if object isa Int and static_type == "Byte" then + # Byte serialized as an integer + return object.to_b + end + return object end