コード例 #1
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);
        }
コード例 #2
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);
        }