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

时间:2024-01-12 15:33:38
            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);