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
<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>