public void DeserializeTest()
        {
            var model = new
            {
                flag = "test",
                datas = new[]
                { 
                    new { age = "10", name = "张" },
                    new { age ="11", name = "陈" } 
                }
            };
            var serializer = new DefaultDynamicJsonSerializer();
            var json = serializer.Serialize(model);

            var jObject = new DefaultDynamicJsonSerializer().Deserialize(json);
            Assert.IsTrue(jObject.Flag == "test");

            var datas = jObject.Datas as IList;
            Assert.IsTrue(datas != null && datas.Count == 2);

            var user = (User)jObject.Datas[0];
            Assert.IsTrue(user != null && user.Name == "张");
        }
Exemple #2
0
 /// <summary>
 /// 执行结果
 /// </summary>
 /// <param name="context">上下文</param>
 public override void ExecuteResult(RequestContext context)
 {
     var json = new DefaultDynamicJsonSerializer().Serialize(this.data);
     context.Response.ContentType = "application/json";
     context.Response.Write(json);
 }