WebEnh

.net7 mvc jquery bootstrap json 学习中 第一次学PHP,正在研究中。自学进行时... ... 我的博客 https://enhweb.github.io/ 不错的皮肤:darkgreentrip,iMetro_HD
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Newtonsoft.Json 把对象转换成json字符串

Posted on 2016-08-23 02:11  WebEnh  阅读(4404)  评论(0编辑  收藏  举报
            var resultJson = new
            {
                records = rowCount,
                page = pageindex,
                //总页数=(总页数+页大小-1)/页大小
                total = (rowCount + pagesize - 1) / pagesize,//总页数
                rows = data.ToList<Web.Entity.Db.Table1Bean>(),
            };

            //JsonResult jr = Json(resultJson, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet);

            //Newtonsoft.Json 把对象转换成json字符串
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(resultJson);