Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
public string MemberDetail(string Code)
{
String res = "";
SortedList sd = new SortedList();
sd.Add("@mode", "MemberDetail");
sd.Add("@Code", Code);
SqlDataReader dr = erp.GetDataReaderSP("[Demo]", sd);
DataTable dt = new DataTable();
dt.Load(dr);
Synchr[] obj = new Synchr[dt.Rows.Count];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
obj[i].DemoName = Convert.ToInt32(dt.Rows[i]["Name"].ToString());
}
}
return new JavaScriptSerializer().Serialize(obj);
}
I assume it is a web service that you are getting the data from (as your question is tagged "web-service"), change maxlength in web.config :
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
Or you can try the MaxJsonLength of JavaScriptSerializer :
JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue;
myObject obj = serializer.Deserialize<yourObject>(yourJsonString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With