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数据太长
时间: 2024-10-15 00:43:23