public void JSON_SerializeRow_ComplexTypedRow_Array() { var row1 = new PersonWithNesting { ID = "A1", FirstName = "Joseph", LastName = "Mc'Cloud", DOB = new DateTime(1953, 12, 10), YearsInSpace = 12, LatestHistory = new HistoryItem { ID = "111", StartDate = DateTime.Now, Description = "Chaplin" }, History1 = new List <HistoryItem> { new HistoryItem { ID = "789211", StartDate = DateTime.Now, Description = "Chaplin with us" }, new HistoryItem { ID = "234234", StartDate = DateTime.Now, Description = "Chaplin with you" } }, History2 = new HistoryItem[2] }; var json = row1.ToJSON(NFX.Serialization.JSON.JSONWritingOptions.PrettyPrint); //AS ARRAY Console.WriteLine(json); var row2 = json.JSONToDynamic(); Assert.AreEqual("A1", row2[row1.Schema["ID"].Order]); Assert.AreEqual("Joseph", row2[row1.Schema["FirstName"].Order]); Assert.AreEqual("Mc'Cloud", row2[row1.Schema["LastName"].Order]); Assert.AreEqual("111", row2[row1.Schema["LatestHistory"].Order][0]); Assert.AreEqual(2, row2[row1.Schema["History1"].Order].Count); Assert.AreEqual("234234", row2[row1.Schema["History1"].Order][1][0]); }
public void JSON_SerializeRow_ComplexTypedRow_Map() { var row1 = new PersonWithNesting { ID = "A1", FirstName = "Joseph", LastName = "Mc'Cloud", DOB = new DateTime(1953, 12, 10), YearsInSpace = 12, LatestHistory = new HistoryItem { ID = "111", StartDate = DateTime.Now, Description = "Chaplin" }, History1 = new List <HistoryItem> { new HistoryItem { ID = "789211", StartDate = DateTime.Now, Description = "Chaplin with us" }, new HistoryItem { ID = "234234", StartDate = DateTime.Now, Description = "Chaplin with you" } }, History2 = new HistoryItem[2] }; var json = row1.ToJSON(NFX.Serialization.JSON.JSONWritingOptions.PrettyPrintRowsAsMap); //AS MAP!!!! Console.WriteLine(json); var row2 = json.JSONToDynamic(); Assert.AreEqual("A1", row2.ID); Assert.AreEqual("Joseph", row2.FirstName); Assert.AreEqual("Mc'Cloud", row2.LastName); Assert.AreEqual("111", row2.LatestHistory.ID); Assert.AreEqual(2, row2.History1.Count); Assert.AreEqual("234234", row2.History1[1].ID); }