示例#1
0
        public void Test_Generic_Parse()
        {
            string      str         = @"{""Id"": 2,""Name"": ""rhis"",""Salary"": 989}";
            JsonHandler handler     = new JsonHandler(str);
            var         originalObj = new DataObj()
            {
                Id = 2, Name = "rhis", Salary = "989"
            };
            var Parsedobj = handler.Parse <DataObj>();

            Assert.AreEqual(originalObj.Equals(Parsedobj), true);
        }
示例#2
0
        public void Test_Dynamic_Parse()
        {
            string      str     = @"{""Id"": 2,""Name"": ""rhis"",""Salary"": 989}";
            JsonHandler handler = new JsonHandler(str);

            var originalObj = new DataObj()
            {
                Id = 2, Name = "rhis", Salary = "989"
            };

            dynamic Parsedobj = handler.Parse();

            Assert.AreEqual((int)Parsedobj.Id, 2);
            Assert.AreEqual((string)Parsedobj.Name, "rhis");
            Assert.AreEqual((string)Parsedobj.Salary, "989");
        }