From 7e4a44d1877e89a9e0db9d086a827559670d01e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Thu, 27 Jul 2017 12:05:13 -0400 Subject: [PATCH] json: deser. chars serialized as strings and bytes as ints MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/json/serialization_read.nit | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- 1.7.9.5