PEIYANGXINQU

 

利用原生态的(System.Web.Extensions)JavaScriptSerializer将mvc 前台提交到controller序列化复杂对象

主要代码如下:

    public JsonResult Test()
        {

            string s = Request.Form.ToString();

            JavaScriptSerializer jss = new JavaScriptSerializer();
            var sth = jss.Deserialize<TestModel>(HttpUtility.UrlDecode(s));
            //var lst = jss.Deserialize<IList<Dictionary<string, string>>>(HttpUtility.UrlDecode(s));
            //s = Request.QueryString[0];
            //
            //to do sth about the data:
            //...
            //...
            return Json(new { id = 1, msg = "ch" });
        }
View Code

当然,也可以直接利用微软的Newtonsoft.Json.JsonConvert.DeserializeObject<T>(strJson)

http://download.csdn.net/detail/yekeyishuo/6471375

posted on 2013-10-29 16:48  PEIYANGXINQU  阅读(243)  评论(0编辑  收藏  举报

导航