public void DeserializeFromJsonTest()
        {
            string    json = @"{""bar"":""foo""}";
            testclass tc   = new testclass();

            tc.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(json));
            Assert.AreEqual("foo", tc.testfield);
        }
        public void DeserializeFromEnumJsonTest()
        {
            string json = @"{""bar"":""foo"",""blah"":""enum2"",""field3"":""yyy""}";

            testclass tc = new testclass();

            tc.testfield  = "asdasd";
            tc.testfield2 = testenum.foo;
            tc.testfield3 = testenum0.xxx;
            tc.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(json));
            Assert.AreEqual("foo", tc.testfield);
            Assert.AreEqual(testenum.bar, tc.testfield2);
            Assert.AreEqual(testenum0.yyy, tc.testfield3);
        }
        public void DeserializeFromArrayJsonTest()
        {
            string json = @"[{""bar"":""foo""},1]";

            object[] objects = JsonConvertibleObject.DeserializeFromJsonArray(json);

            testclass tc = new testclass();

            tc.FromJsonIntermediateObject(objects[0]);
            Assert.AreEqual("foo", tc.testfield);

            int i = JsonConvertibleObject.ObjectToValue <int>(objects[1]);

            Assert.AreEqual(1, i);
        }
コード例 #4
0
        public void SerializeEnumJsonTest()
        {
            string json = @"{""bar"":""foo"",""blah"":""enum2"",""field3"":""yyy""}";

            testclass tc = new testclass();
            tc.testfield = "asdasd";
            tc.testfield2 = testenum.foo;
            tc.testfield3 = testenum0.xxx;
            tc.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(json));
            Assert.AreEqual("foo", tc.testfield);
            Assert.AreEqual(testenum.bar, tc.testfield2);
            Assert.AreEqual(testenum0.yyy, tc.testfield3);

            string json2 = tc.SerializeToJson();

            Assert.AreEqual(json, json2);
        }
コード例 #5
0
 public void DeserializeFromJsonTest()
 {
     string json = @"{""bar"":""foo""}";
     testclass tc = new testclass();
     tc.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(json));
     Assert.AreEqual("foo", tc.testfield);
 }
コード例 #6
0
        public void DeserializeFromArrayJsonTest()
        {
            string json = @"[{""bar"":""foo""},1]";

            object[] objects = JsonConvertibleObject.DeserializeFromJsonArray(json);

            testclass tc = new testclass();
            tc.FromJsonIntermediateObject(objects[0]);
            Assert.AreEqual("foo", tc.testfield);

            int i = JsonConvertibleObject.ObjectToValue<int>(objects[1]);
            Assert.AreEqual(1, i);
        }