13
05/2015
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;
0 条评论