Error During Serialization or Deserialization Using the JSON JavaScriptSerializer

When parsing JSON data in your .NET application, you may experience an error that reads, “Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Parameter name: input”

The error is shown in the below screenshot.

 

To resolve the error, you need to set the MaxJsonLength property to a higher value than what you are using. Probably, you are using the default value.

To set the value of MaxJsonLength, use the syntax below:

C#

var serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue;

VB

Dim jss = New JavaScriptSerializer()           
jss.MaxJsonLength = Int32.MaxValue

 

Ads by Google

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.