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(); Aver.AreEqual("A1", row2[row1.Schema["ID"].Order]); Aver.AreEqual("Joseph", row2[row1.Schema["FirstName"].Order]); Aver.AreEqual("Mc'Cloud", row2[row1.Schema["LastName"].Order]); Aver.AreEqual("111", row2[row1.Schema["LatestHistory"].Order][0]); Aver.AreEqual(2, row2[row1.Schema["History1"].Order].Count); Aver.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(); Aver.AreEqual("A1", row2.ID); Aver.AreEqual("Joseph", row2.FirstName); Aver.AreEqual("Mc'Cloud", row2.LastName); Aver.AreEqual("111", row2.LatestHistory.ID); Aver.AreEqual(2, row2.History1.Count); Aver.AreEqual("234234", row2.History1[1].ID); }