Laughing
asp.net core中bootstrap-table无法获取返回的Json数据
11/29
本文最后更新于2020年09月26日,已超过1310天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
之前在ASP.NET Core下面,通过bootstrap-table也展示过数据,当时也是在controller中直接返回了Json对象,当时没有任何问题,但是今天测试的时候,发现返回的数据不能展示了,所有的数据都变成了 -,其实就是数据有问题,但是查看返回的Json数据的时候,Json数据格式也没有任何问题。
处理Json返回的数据
更多调试发现,Json对象还有一个JsonSerializerSettings参数的重载函数,然后直接实例化了一个JsonSerializerSettings对象,然后返回Json就可以了,具体如下
var rows = productHelper.GetProductPager(limit, offset);
int total = rows.Count();
JsonSerializerSettings settings = new JsonSerializerSettings();
//settings.MaxDepth = 50;
//settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //设置不处理循环引用
//转成Json格式
return Json(new { total = total, rows = rows }, settings);
//return Json(new { total = total, rows = rows });
版权属于:
香草物语
本文链接:
https://www.xiangcaowuyu.net/java/asp-net-core-bootstrap-table-json-data.html(转载时请注明本文出处及文章链接)
作品采用:
能用吗?谢谢分享
谢谢