Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            var        result = MyJsonConvert.MyProcess(MyJsonConvert.MyKeyValue(textBox1.Text.Trim()));
            TestModel1 res    = new TestModel1();
            Stopwatch  sw     = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                MyJsonConvert.MyDtoO(res, result);
            }
            sw.Stop();

            Console.WriteLine("Elapsed={0}", sw.Elapsed);


            Stopwatch sw1 = new Stopwatch();

            sw1.Start();
            for (int i = 0; i < 10000; i++)
            {
                var value = JsonConvert.DeserializeObject <TestModel1>(textBox1.Text.Trim());
            }
            sw1.Stop();

            Console.WriteLine("Elapsed1={0}", sw1.Elapsed);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var model3 = new TestModel3
            {
                Id      = 1,
                listint = new List <int> {
                    1, 23, 4, 32
                },
                liststr = new List <string> {
                    "111", "22", "33"
                }
            };

            var list = new TestModel
            {
                Id      = 1,
                listint = new List <int> {
                    1, 23, 4, 32
                },
                liststr = new List <string> {
                    "111", "22", "33"
                },
                model3 = model3
            };

            var list1 = new TestModel1
            {
                intlist = new List <TestModel> {
                    list, list
                },
                testmodel = list
            };

            var json = JsonConvert.SerializeObject(list1);

            textBox1.Text = json;
        }