From d0a60b8796c1155d1efb373ec35b0d31034c8cd5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 29 Jun 2015 08:28:57 -0400 Subject: [PATCH] lib/json: serialize `Array[nullable Serializable]` as any other arrays MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/json/serialization.nit | 12 ------------ tests/sav/test_json_deserialization_alt1.res | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/json/serialization.nit b/lib/json/serialization.nit index db9b626..be9ee8c 100644 --- a/lib/json/serialization.nit +++ b/lib/json/serialization.nit @@ -437,18 +437,6 @@ redef class SimpleCollection[E] end end -redef class Array[E] - redef fun serialize_to_json(v) - do - if v.plain_json or class_name == "Array[nullable Serializable]" then - # Using class_name to get the exact type, - # we do not want Array[Int] or anything else here. - - serialize_to_pure_json v - else super - end -end - redef class Map[K, V] redef fun serialize_to_json(v) do diff --git a/tests/sav/test_json_deserialization_alt1.res b/tests/sav/test_json_deserialization_alt1.res index 36fed28..52aafb9 100644 --- a/tests/sav/test_json_deserialization_alt1.res +++ b/tests/sav/test_json_deserialization_alt1.res @@ -40,7 +40,7 @@ # Json: -{"__kind": "obj", "__id": 0, "__class": "E", "a": {"__kind": "obj", "__id": 1, "__class": "Array[Object]", "__items": ["hello", 1234, 123.4]}, "b": ["hella", 2345, 234.5]} +{"__kind": "obj", "__id": 0, "__class": "E", "a": {"__kind": "obj", "__id": 1, "__class": "Array[Object]", "__items": ["hello", 1234, 123.4]}, "b": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Serializable]", "__items": ["hella", 2345, 234.5]}} # Back in Nit: -- 1.7.9.5