Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #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);
        }