--- /dev/null
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "A",
+ "b": true,
+ "c": {"__kind": "char", "__val": "a"},
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+}
+
+# Back in Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "B",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+}
+
+# Back in Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "C",
+ "a": {
+ "__kind": "obj", "__id": 1, "__class": "A",
+ "b": true,
+ "c": {"__kind": "char", "__val": "a"},
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+ },
+ "b": {
+ "__kind": "obj", "__id": 2, "__class": "B",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+ },
+ "aa": {
+ "__kind": "ref", "__id": 1
+ }
+}
+
+# Back in Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111 f"\r\/> true>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "D",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "new line ->\n<-",
+ "n": null,
+ "ii": 1111,
+ "ss": "\tf\"\r\\/",
+ "d": {
+ "__kind": "ref", "__id": 0
+ }
+}
+
+# Back in Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111 f"\r\/> true>
+
+# Nit:
+<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",
+ "__items": [
+ "hello",
+ 1234,
+ 123.4
+ ]
+ },
+ "b": {
+ "__kind": "obj", "__id": 2, "__class": "Array",
+ "__items": [
+ "hella",
+ 2345,
+ 234.5
+ ]
+ }
+}
+
+# Back in Nit:
+<E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
+
+# Nit:
+<E: 2222>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "F",
+ "n": 2222
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "F",
+ "n": 33.33
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "G",
+ "hs": {
+ "__kind": "obj", "__id": 1, "__class": "HashSet",
+ "__items": [
+ -1,
+ 0
+ ]
+ },
+ "s": {
+ "__kind": "obj", "__id": 2, "__class": "ArraySet",
+ "__items": [
+ "one",
+ "two"
+ ]
+ },
+ "hm": {
+ "__kind": "obj", "__id": 3, "__class": "HashMap", "__length": 2,
+ "__keys": [
+ "one",
+ "two"
+ ],
+ "__values": [
+ 1,
+ 2
+ ]
+ },
+ "am": {
+ "__kind": "obj", "__id": 4, "__class": "ArrayMap", "__length": 2,
+ "__keys": [
+ "three",
+ "four"
+ ],
+ "__values": [
+ "3",
+ "4"
+ ]
+ }
+}
+
+# Back in Nit:
+<G: hs: ; s: ; hm: ; am: >
+
--- /dev/null
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "A",
+ "b": true,
+ "c": {"__kind": "char", "__val": "a"},
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+}
+
+# Back in Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "B",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+}
+
+# Back in Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "C",
+ "a": {
+ "__kind": "obj", "__id": 1, "__class": "A",
+ "b": true,
+ "c": {"__kind": "char", "__val": "a"},
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+ },
+ "b": {
+ "__kind": "obj", "__id": 2, "__class": "B",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+ },
+ "aa": {
+ "__kind": "ref", "__id": 1
+ }
+}
+
+# Back in Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111 f"\r\/> true>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "D",
+ "b": false,
+ "c": {"__kind": "char", "__val": "b"},
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "new line ->\n<-",
+ "n": null,
+ "ii": 1111,
+ "ss": "\tf\"\r\\/",
+ "d": {
+ "__kind": "ref", "__id": 0
+ }
+}
+
+# Back in Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111 f"\r\/> true>
+
+# Nit:
+<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": {
+ "__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>
+
+# Nit:
+<E: 2222>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "F[Int]",
+ "n": 2222
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "F[Float]",
+ "n": 33.33
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+ "__kind": "obj", "__id": 0, "__class": "G",
+ "hs": {
+ "__kind": "obj", "__id": 1, "__class": "HashSet[Int]",
+ "__items": [
+ -1,
+ 0
+ ]
+ },
+ "s": {
+ "__kind": "obj", "__id": 2, "__class": "ArraySet[String]",
+ "__items": [
+ "one",
+ "two"
+ ]
+ },
+ "hm": {
+ "__kind": "obj", "__id": 3, "__class": "HashMap[String, Int]", "__length": 2,
+ "__keys": [
+ "one",
+ "two"
+ ],
+ "__values": [
+ 1,
+ 2
+ ]
+ },
+ "am": {
+ "__kind": "obj", "__id": 4, "__class": "ArrayMap[String, String]", "__length": 2,
+ "__keys": [
+ "three",
+ "four"
+ ],
+ "__values": [
+ "3",
+ "4"
+ ]
+ }
+}
+
+# Back in Nit:
+<G: hs: ; s: ; hm: ; am: >
+
--- /dev/null
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+ "b": true,
+ "c": "a",
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+}
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+ "b": false,
+ "c": "b",
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+}
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Json:
+{
+ "a": {
+ "b": true,
+ "c": "a",
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+ },
+ "b": {
+ "b": false,
+ "c": "b",
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "hjkl",
+ "n": 12,
+ "ii": 1111,
+ "ss": "qwer"
+ },
+ "aa": {
+ "b": true,
+ "c": "a",
+ "f": 0.123,
+ "i": 1234,
+ "serialization_specific_name": "asdf",
+ "n": null
+ }
+}
+
+Serialization warning: Cycle detected in serialized object, replacing reference with 'null'.
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111 f"\r\/> true>
+
+# Json:
+{
+ "b": false,
+ "c": "b",
+ "f": 123.123,
+ "i": 2345,
+ "serialization_specific_name": "new line ->\n<-",
+ "n": null,
+ "ii": 1111,
+ "ss": "\tf\"\r\\/",
+ "d": null
+}
+
+# Nit:
+<E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
+
+# Json:
+{
+ "a": [
+ "hello",
+ 1234,
+ 123.4
+ ],
+ "b": [
+ "hella",
+ 2345,
+ 234.5
+ ]
+}
+
+# Nit:
+<E: 2222>
+
+# Json:
+{
+ "n": 2222
+}
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+ "n": 33.33
+}
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+ "hs": [
+ -1,
+ 0
+ ],
+ "s": [
+ "one",
+ "two"
+ ],
+ "hm": {
+ "one": 1,
+ "two": 2
+ },
+ "am": {
+ "three": "3",
+ "four": "4"
+ }
+}
+
var entities = new TestEntities
-var tests = entities.without_generics#alt1##alt2#
+var tests = entities.without_generics#alt1##alt2##alt3##alt4#
#alt1#var tests = entities.with_generics
#alt2#var tests = entities.with_generics
+#alt3#var tests = entities.with_generics
+#alt4#var tests = entities.with_generics
for o in tests do
var stream = new StringWriter
var serializer = new JsonSerializer(stream)
#alt2#serializer.plain_json = true
+ #alt3#serializer.pretty_json = true
+ #alt4#serializer.plain_json = true
+ #alt4#serializer.pretty_json = true
serializer.serialize(o)
- var deserializer = new JsonDeserializer(stream.to_s)#alt2#
- var deserialized = deserializer.deserialize#alt2#
+ var deserializer = new JsonDeserializer(stream.to_s)#alt2##alt4#
+ var deserialized = deserializer.deserialize#alt2##alt4#
print "# Nit:\n{o}\n"
print "# Json:\n{stream}\n"
- print "# Back in Nit:\n{deserialized or else "null"}\n"#alt2#
+ print "# Back in Nit:\n{deserialized or else "null"}\n"#alt2##alt4#
end