public void TestDictionaryType() { var target = new Hashtable(2); target["A"] = "A"; target["B"] = new TwoLevel() { Name = 1122, U = "First" }; //GlobalJsonCompileSetting.Config(new JsonCompileSetting() { UseNumberInEnum = true }); Console.WriteLine("target:" + target.ToString()); var text = EasyJsonSerializer.Serialize(target); Console.WriteLine("target:" + text); target = EasyJsonSerializer.Deserialize <Hashtable>(text); Console.WriteLine("target:" + target.ToString()); Console.WriteLine("-----------------------"); target = new Hashtable(2); target["A"] = "A"; target["B"] = new TwoLevel() { Name = 1122, U = "First" }; Console.WriteLine("target:" + target.ToString()); text = EasyJsonSerializer.Serialize(target); Console.WriteLine("target:" + text); var target2 = EasyJsonSerializer.Deserialize <System.Collections.Generic.Dictionary <string, string> >(text); Console.WriteLine("target:" + target.ToString()); Console.WriteLine("-----------------------"); }
public void TestTwoLevel() { var two = new TwoLevel() { U = "36}", }; var text = EasyJsonSerializer.Serialize(two); var twoc = EasyJsonSerializer.Deserialize <TwoLevelCopy>(text); }
public void TestArrayArrayIntType() { var target = new TwoLevel[][] { new TwoLevel[] { new TwoLevel { Name = 234, U = "E", }, new TwoLevel { Name = 54687, U = "EET" } } }; Console.WriteLine("target:"); foreach (var i in target) { Console.WriteLine(i.ToString() + ","); } var text = EasyJsonSerializer.Serialize(target); target = EasyJsonSerializer.Deserialize <TwoLevel[][]>(text); Console.WriteLine("target:"); foreach (var i in target) { Console.WriteLine(i.ToString() + ","); } Console.WriteLine("-----------------------"); Console.WriteLine("target:"); foreach (var i in target) { Console.WriteLine(i.ToString() + ","); } text = EasyJsonSerializer.Serialize(target); var target2 = EasyJsonSerializer.Deserialize <ICollection <TwoLevel[]> >(text); Console.WriteLine("target:"); foreach (var i in target2) { Console.WriteLine(i.ToString() + ","); } Console.WriteLine("-----------------------"); }
public void TestGenericDictionaryType() { var dict = new Dictionary <int, TwoLevel>(2); dict[1] = new TwoLevel() { Name = 1122, U = "First" }; dict[2] = new TwoLevel() { Name = 3344, U = "Secode" }; var text = EasyJsonSerializer.Serialize(dict); Console.WriteLine(text); var target2 = EasyJsonSerializer.Deserialize <System.Collections.Generic.Dictionary <int, TwoLevel> >(text); }
public void TestOTo2Array() { var v = new TwoLevel[][] { new TwoLevel[] { new TwoLevel { Name = 234 }, new TwoLevel { Name = 234 } }, null, new TwoLevel[] { new TwoLevel { Name = 234 }, new TwoLevel { Name = 234 } }, }; var text = Never.Serialization.EasyJsonSerializer.Serialize(v); text = Newtonsoft.Json.JsonConvert.SerializeObject(v); var list = Never.Serialization.Json.ThunderReader.Load(text); v = Never.Serialization.EasyJsonSerializer.Deserialize <TwoLevel[][]>(text); v = Newtonsoft.Json.JsonConvert.DeserializeObject <TwoLevel[][]>(text); }
public void TestArrayObjectType() { var target = new TwoLevel[] { new TwoLevel { Name = 234, Three = new ThreeLevel() { } }, null, new TwoLevel { Name = 5465 } }; Console.WriteLine("target:"); foreach (var i in target) { if (i == null) { continue; } Console.WriteLine(i.ToString() + ","); } var text = EasyJsonSerializer.Serialize(target); target = EasyJsonSerializer.Deserialize <TwoLevel[]>(text); Console.WriteLine("target:"); foreach (var i in target) { if (i == null) { continue; } Console.WriteLine(i.ToString() + ","); } Console.WriteLine("-----------------------"); Console.WriteLine("target:"); foreach (var i in target) { if (i == null) { continue; } Console.WriteLine(i.ToString() + ","); } text = EasyJsonSerializer.Serialize(target); var target2 = EasyJsonSerializer.Deserialize <List <TwoLevel> >(text); Console.WriteLine("target:"); foreach (var i in target2) { if (i == null) { continue; } Console.WriteLine(i.ToString() + ","); } Console.WriteLine("-----------------------"); }