private void SerializeBtn(object sender, RoutedEventArgs e) { Random ran = new Random(); RootClass newClass = new RootClass(); newClass.ArrayDouble = new double[] { ran.NextDouble(), ran.NextDouble() }; newClass.ArrayInt = new int[] { ran.Next(), ran.Next() }; newClass.Hour = DateTime.Now.Hour; newClass.Seconds = DateTime.Now.Second; newClass.Say = ran.Next().ToString() + " = Число"; newClass.Object1 = new ClassName0() { Exp = 2.718, PI = 3.14 }; newClass.Object2 = new ClassName1() { Speed = ran.NextDouble() * 100 }; newClass.Object3 = new ClassName2() { Power = new ClassName4() { Wattage = ran.Next() } }; newClass.Object4 = new ClassName3() { Current = new ClassName5() { Active = new ClassName6() { Sin = ran.NextDouble() } } }; JSONBox.Text = JSONConverter.Serialize(newClass); }
private void button1_Click(object sender, RoutedEventArgs e) { RootClass newClass = JSONConverter.Deserialize <RootClass>(JSONBox.Text); }