废话不说,直接上代码
public ActionResult GetUnreadMailJsonByApp()
{
string userId = OperatorProvider.Provider.Current().UserId;
var data = emailContentBLL.GetUnreadMail( userId);
var JsonData = new
{
rows = data,
total = pagination.total,
page = pagination.page,
records = pagination.records,
costtime = CommonHelper.TimerEnd(watch)
};
return Content(JsonData.ToJson());
}
把 上面的多个对象通过JsonData进行封装。
当然,自己按照Json格式封装也可以,就是拼接字符串,格式为 {"obj1":"xxx","obj2":{"ff":"ff1","ffse","ffwwe"}},如果想看自己的Json字符串格式对不对,有在线测试的网站,直接复制过去就可以了。