diff --git a/docs/deserialization.md b/docs/deserialization.md index 513ea3b..45c2531 100644 --- a/docs/deserialization.md +++ b/docs/deserialization.md @@ -15,6 +15,7 @@ struct Person public float[] list3; public double[] list4; public string[] list5; + public EnumType animal; } ``` @@ -31,7 +32,8 @@ Now, let's say we were given the following JSON: "list2": [true, false], "list3": [1.5, 1.4], "list4": [1.5, 1.4], - "list5": ["baba", "booey"] + "list5": ["baba", "booey"], + "animal": "CAT" } ``` @@ -49,7 +51,8 @@ JSONValue json = parseJSON(`{ "list2": [true, false], "list3": [1.5, 1.4], "list4": [1.5, 1.4], -"list5": ["baba", "booey"] +"list5": ["baba", "booey"], +"animal": "CAT" } `); @@ -66,5 +69,5 @@ writeln(person): Which will output: ``` -Person("Tristan", "Kildaire", 23, true, {"bruh":1}, [1, 2, 3], [true, false], [1.5, 1.4], [1.5, 1.4], ["baba", "booey"]) +Person("Tristan", "Kildaire", 23, true, {"bruh":1}, [1, 2, 3], [true, false], [1.5, 1.4], [1.5, 1.4], ["baba", "booey"], CAT) ``` \ No newline at end of file diff --git a/docs/serialization.md b/docs/serialization.md index a25a4f1..5fb1a5a 100644 --- a/docs/serialization.md +++ b/docs/serialization.md @@ -10,6 +10,17 @@ struct Person public int age; public string[] list; public JSONValue extraJSON; + public EnumType eType; +} +``` + +Our enum is defined as: + +```d +enum EnumType +{ + DOG, + CAT } ``` @@ -22,6 +33,7 @@ p1.lastname = "Kildaire"; p1.age = 23; p1.list = ["1", "2", "3"]; p1.extraJSON = parseJSON(`{"item":1, "items":[1,2,3]}`); +p1.eType = EnumType.CAT; ``` Now, we make a call to `serializeRecord` as follows: @@ -35,6 +47,7 @@ This returns the following JSON: ```json { "age": 23, + "eType": "CAT", "extraJSON": { "item": 1, "items": [ @@ -45,6 +58,10 @@ This returns the following JSON: }, "firstname": "Tristan", "lastname": "Kildaire", - "list": ["1", "2", "3"] + "list": [ + "1", + "2", + "3" + ] } ``` \ No newline at end of file