예제 #1
0
파일: Tests.cs 프로젝트: qyezzard/PowerJSON
        public void ClassTest()
        {
            Retclass r = new Retclass();

            r.Name   = "hello";
            r.Field1 = "dsasdF";
            r.Field2 = 2312;
            r.date   = DateTime.Now;
#if !SILVERLIGHT
            r.ds = CreateDataset().Tables[0];
#endif

            var s = JSON.ToJSON(r);
            Console.WriteLine(JSON.Beautify(s));
            var o = JSON.ToObject(s);

            Assert.AreEqual(2312, (o as Retclass).Field2);
        }
예제 #2
0
파일: Tests.cs 프로젝트: qyezzard/PowerJSON
        public void ParseTest()
        {
            Retclass r = new Retclass();

            r.Name   = "hello";
            r.Field1 = "dsasdF";
            r.Field2 = 2312;
            r.date   = DateTime.Now;
#if !SILVERLIGHT
            r.ds = CreateDataset().Tables[0];
#endif

            var s = JSON.ToJSON(r);
            Console.WriteLine(s);
            var o = JSON.Parse(s);

            Assert.IsNotNull(o);
        }
예제 #3
0
파일: Tests.cs 프로젝트: qyezzard/PowerJSON
        public void lowercaseSerilaize()
        {
            Retclass r = new Retclass();

            r.Name   = "Hello";
            r.Field1 = "dsasdF";
            r.Field2 = 2312;
            r.date   = DateTime.Now;
            var s = JSON.ToNiceJSON(r, new JSONParameters {
                SerializeToLowerCaseNames = true
            });

            Console.WriteLine(s);
            var o = JSON.ToObject(s);

            Assert.IsNotNull(o);
            Assert.AreEqual("Hello", (o as Retclass).Name);
            Assert.AreEqual(2312, (o as Retclass).Field2);
        }
예제 #4
0
        public void lowercaseSerilaize()
        {
            Retclass r = new Retclass();

            r.Name   = "Hello";
            r.Field1 = "dsasdF";
            r.Field2 = 2312;
            r.date   = DateTime.Now;
            var s = Json.ToJson(r, new SerializationManager {
                NamingConvention = NamingConvention.LowerCase
            });

            Console.WriteLine(s);
            var o = Json.ToObject(s);

            Assert.IsNotNull(o);
            Assert.AreEqual("Hello", (o as Retclass).Name);
            Assert.AreEqual(2312, (o as Retclass).Field2);
        }