protected override void OnConfirm()
        {
            string food = foodType.ToString();

            m_changes[food] = new CookingTime
            {
                name    = "",
                enabled = enabled,
                cooking = cooking,
                burning = burning,
            };
            m_changes.ToList().ForEach(delegate(KeyValuePair <string, CookingTime> x)
            {
                m_food[x.Key] = new CookingTime
                {
                    name    = m_food[x.Key].name,
                    enabled = x.Value.enabled,
                    cooking = x.Value.cooking,
                    burning = x.Value.burning,
                };;
            });
            SaveDataProxy data = new SaveDataProxy
            {
                water = m_water,
                food  = m_food
            };

            string settings = FastJson.Serialize(data);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CookingTweaks.json"), settings);
        }
Esempio n. 2
0
        void Start()
        {
            ExampleClass foo = new ExampleClass();

            foo.id   = 1234;
            foo.name = "SampleClass";

            string jsonText = FastJson.Serialize(foo);

            Debug.Log(jsonText);

            ExampleClass fooDecode = FastJson.Deserialize <ExampleClass>(jsonText);

            Debug.Log("id=" + fooDecode.id + " name=" + fooDecode.name);


            int[][][] bar = new int[][][] {
                new int[][]
                {
                    new int[] { 1 },
                    new int[] { 2, 3 }
                },
                new int[][] {
                    new int[] { 4, 5, 6 }
                },
                null
            };

            jsonText = FastJson.Serialize(bar);
            Debug.Log(jsonText);

            int[][][] barDecode = (int[][][])FastJson.Deserialize(jsonText, typeof(int[][][]));
            Debug.Log(ToString(barDecode));
        }
Esempio n. 3
0
    public string Serialize(Stopwatch timer)
    {
        timer.Start();
        string s = FastJson.Serialize(jsonData);

        return("Resulting json is " + s.Length.ToString("n0") + " characters");
    }
Esempio n. 4
0
        private void Test_Example2()
        {
            ClassA tempA = new ClassA();

            // 循环嵌套会直接造成崩溃
            //tempA.SetNext(tempA);

            ClassA tempAnotherA = new ClassA();

            tempA.SetA(tempAnotherA);

            ClassB tempB = new ClassB();

            tempA.SetB(tempB);

            ClassC tempC = new ClassC();

            tempA.SetC(tempC);

            tempA.SetGameObject(this.gameObject);

            // 测试 反序列化
            string jsonStr      = FastJson.Serialize(tempA);
            ClassA deserializeA = FastJson.Deserialize <ClassA>(jsonStr);

            Debug.Log(FastJson.Serialize(deserializeA));
        }
Esempio n. 5
0
        protected override void OnConfirm()
        {
            DetectionRange.m_animals["wolf"] = GetSettings();

            string settings = FastJson.Serialize(m_animals);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DetectionRange.json"), settings);
        }
        protected override void OnConfirm()
        {
            TweakRabbits.killOnHit    = killOnHit;
            TweakRabbits.stunDuration = stunDuration;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TweakRabbits.json"), settings);
        }
        protected override void OnConfirm()
        {
            FasterActionRedux.containerTime = containerTime;
            FasterActionRedux.actionTime    = actionTime;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FasterActionRedux.json"), settings);
        }
Esempio n. 8
0
            protected override void OnConfirm()
            {
                TempDropOptions.temp_drop_celsius_max = temp_drop_celsius_max;


                string json_opts = FastJson.Serialize(this);

                File.WriteAllText(Path.Combine(mod_options_folder, options_file_name), json_opts);
            }
Esempio n. 9
0
            protected override void OnConfirm()
            {
                GearDecayOptions.general_decay       = general_decay;
                GearDecayOptions.decay_before_pickup = decay_before_pickup;

                string json_opts = FastJson.Serialize(this);

                File.WriteAllText(Path.Combine(mod_options_folder, options_file_name), json_opts);
            }
Esempio n. 10
0
        protected override void OnConfirm()
        {
            SkipIntroRedux.skipDisclaimer = skipDisclaimer;
            SkipIntroRedux.skipIntro      = skipIntro;
            SkipIntroRedux.skipFade       = skipFade;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SkipIntroRedux.json"), settings);
        }
        protected override void OnConfirm()
        {
            TimeAccelerator.accelerationKey   = KeyCode.A + accelerationKey;
            TimeAccelerator.holdToAccelerate  = accelerationBehaviour == 0;
            TimeAccelerator.accelerationValue = accelerationValue;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TimeAccelerator.json"), settings);
        }
Esempio n. 12
0
        protected override void OnConfirm()
        {
            StruggleTweaks.chanceToKillWolfAfterStruggle = chanceToKillWolfAfterStruggle;
            StruggleTweaks.wolfBleedoutMinutes           = wolfBleedoutMinutes;
            StruggleTweaks.tapIncrement = tapIncrement;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "StruggleTweaks.json"), settings);
        }
        protected override void OnConfirm()
        {
            WeaponCrosshair.stoneCrosshair = stoneCrosshair;
            WeaponCrosshair.rifleCrosshair = rifleCrosshair;
            WeaponCrosshair.bowCrosshair   = bowCrosshair;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "WeaponCrosshair.json"), settings);
        }
Esempio n. 14
0
        private static void SaveDataToJson <T>(T data, bool isSaveWithCloud = false) where T : IDataBase
        {
            var saveJson = FastJson.Serialize(data);
            var typeName = data.GetType().Name;

            PlayerPrefs.SetString(typeName, saveJson);

            if (isSaveWithCloud)
            {
                _saveCloudAction?.Invoke(typeName, saveJson);
            }
        }
Esempio n. 15
0
        protected override void OnConfirm()
        {
            MapTweaks.overrideDrawingRange = overrideDrawingRange;
            MapTweaks.drawingRange         = drawingRange;

            // force disable
            MapTweaks.autodrawEnabled = false;
            MapTweaks.autodrawDelay   = autodrawDelay;

            string settings = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MapTweaks.json"), settings);
        }
Esempio n. 16
0
    void Start()
    {
        CipherInt i = new CipherInt();

        i.value = 123;

        string json = FastJson.Serialize(i);

        Debug.Log(json);

        CipherInt d = FastJson.Deserialize <CipherInt>(json);

        Debug.Log(d.value);
    }
Esempio n. 17
0
    private void Test_8_FastJsonMyText()
    {
        string jsonString = "{\"StringField\":\"ha\\\"ha\\\"ha\"}";

        VeerDebug.Log("json string : " + jsonString);

        TestJsonConvert test = FastJson.Deserialize <TestJsonConvert>(jsonString);

        VeerDebug.Log("fast json string field : " + test.StringField);

        string serialize = FastJson.Serialize(test);

        VeerDebug.Log("fast json serialize : " + serialize);
    }
Esempio n. 18
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));
        }
        protected override void OnConfirm()
        {
            m_water.enabled = enabled;
            m_water.melting = melting;
            m_water.boiling = boiling;
            m_water.drying  = drying;

            SaveDataProxy data = new SaveDataProxy
            {
                water = m_water,
                food  = m_food
            };

            string settings = FastJson.Serialize(data);

            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CookingTweaks.json"), settings);
        }
        protected override void OnConfirm()
        {
            AmbientLightsOptions.enable_shadows         = false;
            AmbientLightsOptions.intensity_multiplier   = intensity_multiplier;
            AmbientLightsOptions.range_multiplier       = range_multiplier;
            AmbientLightsOptions.aurora_intensity       = aurora_intensity;
            AmbientLightsOptions.disable_aurora_flicker = disable_aurora_flicker;
            AmbientLightsOptions.night_brightness       = night_brightness;
            AmbientLightsOptions.enable_debug_key       = enable_debug_key;

            AmbientLightControl.light_override = false;
            AmbientLightControl.MaybeUpdateLightsToPeriod(true);

            string json_opts = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(AmbientLightControl.mod_data_folder, "config.json"), json_opts);
        }
Esempio n. 21
0
    private void Test_9_FastJsonSerialize()
    {
        JSONObject json = JSONObject.obj;

        json.AddField("StringField", TestInnerJsonText);

        string jsonString = json.ToString();

        VeerDebug.Log("json to string : " + jsonString);

        TestJsonConvert test = FastJson.Deserialize <TestJsonConvert>(jsonString);

        VeerDebug.Log("fast json string field : " + test.StringField);

        string serialize = FastJson.Serialize(test);

        VeerDebug.Log("fast json serialize : " + serialize);
    }
Esempio n. 22
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));
        }
Esempio n. 23
0
        private void Test_Example3()
        {
            ClassD tempD = new ClassD();

            tempD.class_c_list  = new List <ClassC>();
            tempD.class_c_array = new ClassC[3];
            tempD.class_c_dic   = new Dictionary <string, ClassC>();

            ClassC c1 = new ClassC();

            c1.c_tag = "c1";
            tempD.class_c_list.Add(c1);
            tempD.class_c_array[0] = c1;
            tempD.class_c_dic.Add("c0", c1);

            ClassC c2 = new ClassC();

            c2.c_tag = "c2";
            tempD.class_c_list.Add(c2);
            tempD.class_c_array[1] = c2;
            tempD.class_c_dic.Add("c1", c2);

            ClassC c3 = new ClassC();

            c3.c_tag = "c3";
            tempD.class_c_list.Add(c3);
            tempD.class_c_array[2] = c3;
            tempD.class_c_dic.Add("c2", c3);

            string jsonStr = FastJson.Serialize(tempD);

            Debug.Log(jsonStr);

            // 反序列化后其 list array dic 内容不再是相同引用,考虑限制 List 和 Array 的反序列化
            ClassD deserializeD = FastJson.Deserialize <ClassD>(jsonStr);

            Debug.Log(FastJson.Serialize(deserializeD));
        }
    void Test1 <T, U>(string name, GenerateFunc <U> generate) where T : new()
    {
        resultText = new StringBuilder();

        T obj = GenerateTestData2 <T, U>(generate);

        Stopwatch("FastJson,s," + name, () => { FastJson.Serialize(obj); });
        //Stopwatch( "EasyJson,s,"+name,	()=>{ EasyJSON.Serializer.Serialize(obj); } );
        //Stopwatch( "XML-JSON,s,"+name,	()=>{ JSONSerializer.Serialize(obj); } );
        //Stopwatch( "JSON.NET,s,"+name,    ()=>{ Newtonsoft.Json.JsonConvert.SerializeObject(obj); } );

        string fastJsonText = FastJson.Serialize(obj);

        //string jsonDotNetText = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
        //string easyJsonText = EasyJSON.Serializer.Serialize(obj);
        //string xmlJsonText = JSONSerializer.Serialize(obj);

        Stopwatch("FastJson,d," + name, () => { FastJson.Deserialize <T>(fastJsonText); });
        //Stopwatch( "EasyJson,d,"+name,	()=>{ EasyJSON.Serializer.Deserialize<T>(easyJsonText); } );
        //Stopwatch( "XML-JSON,d,"+name,	()=>{ JSONSerializer.Deserialize<T>(xmlJsonText); } );
        //Stopwatch( "JSON.NET,d,"+name,    ()=>{ Newtonsoft.Json.JsonConvert.DeserializeObject<T>(jsonDotNetText); } );

        Debug.Log(resultText.ToString());
    }