lib/json: serialize `Array[nullable Serializable]` as any other arrays
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 29 Jun 2015 12:28:57 +0000 (08:28 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 29 Jun 2015 12:39:30 +0000 (08:39 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/json/serialization.nit
tests/sav/test_json_deserialization_alt1.res

index db9b626..be9ee8c 100644 (file)
@@ -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
index 36fed28..52aafb9 100644 (file)
@@ -40,7 +40,7 @@
 <E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
 
 # 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:
 <E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>