返回json数据过大溢出处理

话不多说,直接上代码

public ContentResult ConvertToMaxJson(object obj)
        {
            return new ContentResult
            {
                Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(obj),
                ContentType = "application/json"
            };
        }

其实很简单,创建序列化实例时将MaxJsonLength属性设置为int类型的最大值即可

猜你喜欢

转载自blog.csdn.net/cslx5zx5/article/details/91384315