public void FromJson()
        {
            var target = new Target()
            {
                Targets =
                {
                    new Target1(),
                    new Target2()
                }
            };

            var binder = new ConvertTypeNameBinder();
            JsonSerializerSettings settings = JsonNetUtility.CreateDefault();

            settings.SerializationBinder = binder;

            binder.Provider.Add <Target1>("target1");
            binder.Provider.Add <Target2>("target2");

            string result  = JsonNetUtility.ToJson(target, settings);
            var    result2 = JsonNetUtility.FromJson <Target>(result, settings);

            Assert.NotNull(result2);
            Assert.IsNotEmpty(result2.Targets);
            Assert.AreEqual(2, result2.Targets.Count);
        }
        public void ToJsonAbstract()
        {
            var target = new Target3();

            string actual   = JsonNetUtility.ToJson((object)target);
            string expected = Resources.Load <TextAsset>("data0_1").text;

            Assert.AreEqual(expected, actual);
        }
        public void ToJsonGeneric()
        {
            var target = new Target3();

            string actual   = JsonNetUtility.ToJson(target);
            string expected = Resources.Load <TextAsset>("data0").text;

            Assert.AreEqual(expected, actual);
        }
        public void ToJson()
        {
            var target = new Target()
            {
                Targets =
                {
                    new Target1(),
                    new Target2()
                }
            };

            var binder = new ConvertTypeNameBinder();
            JsonSerializerSettings settings = JsonNetUtility.CreateDefault();

            settings.SerializationBinder = binder;

            binder.Provider.Add <Target1>("target1");
            binder.Provider.Add <Target2>("target2");

            string result = JsonNetUtility.ToJson(target, settings, true);

            Assert.Pass(result);
        }