예제 #1
0
        public void SerializerTest()
        {
            JsonSerializer jsonSerializer = new JsonSerializer();
            JsonBean       bean           = new JsonBean()
            {
                BeanId = 1, BeanName = "first bean", CreateDate = DateTime.Now
            };
            string jsonString = jsonSerializer.Serialize(bean);

            Console.WriteLine(jsonString);
        }
예제 #2
0
        public void DeserializerTest()
        {
            JsonSerializer jsonSerializer = new JsonSerializer();
            JsonBean       bean           = new JsonBean()
            {
                BeanId = 1, BeanName = "first bean", CreateDate = DateTime.Now
            };
            string jsonString            = jsonSerializer.Serialize(bean);
            JsonBeanWithProperty newBean = jsonSerializer.Deserialize <JsonBeanWithProperty>(jsonString);

            Console.WriteLine(newBean.Id + newBean.Name + newBean.Date + newBean.Error);
        }
예제 #3
0
        public void SerializerWithJsonPropertyTest()
        {
            JsonSerializer       jsonSerializer = new JsonSerializer();
            JsonBeanWithProperty bean           = new JsonBeanWithProperty()
            {
                Id = 2, Name = "second bean", Date = DateTime.Now, Error = "error"
            };
            string jsonString = jsonSerializer.Serialize(bean);

            Console.WriteLine(jsonString);
            JsonBean newBean = jsonSerializer.Deserialize <JsonBean>(jsonString);

            Console.WriteLine(newBean.BeanId + newBean.BeanName + newBean.CreateDate);
        }