2 import json_serialization
16 init(b
: Bool, c
: Char, f
: Float, i
: Int, s
: String, n
: nullable Int)
25 redef fun to_s
do return "<A: {b} {c} {f} {i} {s} {n != null}>"
36 init(b
: Bool, c
: Char, f
: Float, i
: Int, s
: String, n
: nullable Int, ii
: Int, ss
: String)
38 super(b
, c
, f
, i
, s
, n
)
44 redef fun to_s
do return "<B: {super} {ii} {ss}>"
47 # Composed of an A and a B
63 redef fun to_s
do return "<C: {a} {b}>"
66 # Class with cyclic reference
71 var d
: nullable D
= null
73 redef fun to_s
do return "<D: {super} {d != null}>"
76 var a
= new A
(true, 'a', 0.1234, 1234, "asdf", null)
77 var b
= new B
(false, 'b', 123.123, 2345, "hjkl", 12, 1111, "qwer")
79 var d
= new D
(false, 'b', 123.123, 2345, "new line ->\n<-", null, 1111, "\t\f\"\r\\
/")
82 for o in new Array[nullable Serializable].with_items(a, b, c, d) do
83 var stream = new StringOStream
84 var serializer = new JsonSerializer(stream)
85 serializer.serialize(o)
88 print
"# Json:\n{stream}\n"