C# JavaScriptSerializer报错,json数据太长

ASP.NET平台中,用JavaScriptSerializer将返回的数据序列化,若返回的数据非常大,则可能会报如下错误:

Exception information: 
Exception type: InvalidOperationException 
Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

解决办法如下:

在实例化JavaScriptSerializer对象后,指定MaxJsonLength。

System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
jss.MaxJsonLength = int.MaxValue;


转载请注明:康瑞的部落 ? C# JavaScriptSerializer报错,json数据太长
文章来自:http://blog.csdn.net/kangrydotnet/article/details/45693789
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3