Beispiel #1
0
        private void Test_Example7()
        {
            // 验证 MethodInfo.MakeGenericMethod() Type类驱动泛型方法
            ClassF f = new ClassF();

            f.f_int = 666;
            string jsonStr = FastJson.Serialize(f);

            Debug.Log(jsonStr);

            MethodInfo mi           = typeof(FastJson).GetMethod("Deserialize", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(typeof(ClassF));
            ClassB     deserializeF = mi.Invoke(null, new object[] { jsonStr }) as ClassB;

            Debug.Log(FastJson.Serialize(deserializeF));
            Debug.Log(FastJson.Serialize(deserializeF as ClassF));
        }
Beispiel #2
0
        private void Test_Example4()
        {
            ClassE e = new ClassE();
            ClassB b = new ClassB();
            ClassF f = new ClassF();
            ClassG g = new ClassG();

            e.class_b_list.Add(b);
            e.class_b_list.Add(f);
            e.class_b_list.Add(g);

            // 测试 反序列化
            string jsonStr = FastJson.Serialize(e);

            Debug.Log(jsonStr);
            ClassE deserializeE = FastJson.Deserialize <ClassE>(jsonStr);

            Debug.Log(FastJson.Serialize(deserializeE));
        }