Ejemplo n.º 1
0
        public static void Test_FastJson_02()
        {
            Trace.WriteLine("Test_FastJson_02");
            //string file = Path.Combine(w._dataDir, "Test_FastJson_02.txt");
            string file = Path.Combine(GetDirectory(), "Test_FastJson_02.txt");

            FastJsonToJson(file, new Test_01 {
                text = "toto", i = 1
            });
            Test_01 test = FastJsonToObject <Test_01>(file);

            test.zView();
        }
Ejemplo n.º 2
0
        public static void Test_FastJson_Test_01_02()
        {
            // Test_FastJson_01 project : ok
            // runsource : ok
            Trace.WriteLine("Test_FastJson_Test_01_02");
            string json = "{\"text\":\"toto\",\"i\":1}";

            Trace.WriteLine("json :");
            Trace.WriteLine(json);
            Trace.WriteLine("JSON.ToObject<Test_01>(json)");
            Test_01 test = JSON.ToObject <Test_01>(json);

            Trace.WriteLine("test.text \"{0}\"", test.text);
            Trace.WriteLine("test.i    {0}", test.i);
        }
Ejemplo n.º 3
0
        public static void Test_Type_01()
        {
            // bug
            // Type.GetType("Test_FastJson.Test_01, RunSource_00011, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null") return null
            Trace.WriteLine();
            Trace.WriteLine("Test_Type_01");
            Test_01 test = new Test_01 {
                text = "toto", i = 1
            };
            Type type = test.GetType();

            Trace.WriteLine("type.Name                    \"{0}\"", type.Name);
            Trace.WriteLine("type.FullName                \"{0}\"", type.FullName);
            Trace.WriteLine("type.AssemblyQualifiedName   \"{0}\"", type.AssemblyQualifiedName);
            Type type2 = Type.GetType(type.FullName);

            Trace.WriteLine("Type.GetType(\"{0}\")   {1}", type.FullName, type2 == null ? "null" : type2.AssemblyQualifiedName);
            type2 = Type.GetType(type.AssemblyQualifiedName);
            Trace.WriteLine("Type.GetType(\"{0}\")   {1}", type.AssemblyQualifiedName, type2 == null ? "null" : type2.AssemblyQualifiedName);
        }
Ejemplo n.º 4
0
        public static void Test_FastJson_Test_01_01()
        {
            // Test_FastJson_01 project : ok
            //   json : {"$types":{"Test_FastJson_01.Test_01, Test_FastJson_01, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null":"1"},"$type":"1","text":"toto","i":1}
            // runsource : error Cannot determine type (System.Exception)
            //   json : {"$types":{"Test_Unit.Test_01, RunSource_00003, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null":"1"},"$type":"1","text":"toto","i":1}
            //   at at fastJSON.deserializer.ParseDictionary(Dictionary`2 d, Dictionary`2 globaltypes, Type type, Object input) in C:\pib\dropbox\pbeuz\Dropbox\dev\project\Tools\fastJSON\fastJSON_v2.1.1\fastJSON\JSON.cs:line 528
            //   bug Type.GetType("Test_FastJson.Test_01, RunSource_00011, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null") return null
            Trace.WriteLine("Test_FastJson_Test_01_01");
            Test_01 test1 = new Test_01 {
                text = "toto", i = 1
            };

            Trace.WriteLine("JSON.ToJSON(test1)");
            string json = JSON.ToJSON(test1);

            Trace.WriteLine("json :");
            Trace.WriteLine(json);
            Trace.WriteLine("JSON.ToObject<Test_01>(json)");
            Test_01 test2 = JSON.ToObject <Test_01>(json);

            Trace.WriteLine("test2.text \"{0}\"", test2.text);
            Trace.WriteLine("test2.i    {0}", test2.i);
        }