We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error during serialization or deserialization using the JSON JavaScriptSerializer

Thread ID:





119571 Jul 9,2015 06:50 PM UTC Jul 13,2015 05:46 PM UTC ASP.NET MVC 3
Tags: TreeGrid
Harry Zheng
Asked On July 9, 2015 06:50 PM UTC

I am trying to display hierarchical data in treegrid and when the records is large, I got the following error:

"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "

I read some discussions about this issue in the forum, but it seems those solutions are not for asp.net mvc 5 and treegrid, which I am working with.
Are there other solutions that works for asp.net mvc 5 and treegrid?


Mahalakshmi Karthikeyan [Syncfusion]
Replied On July 10, 2015 12:37 PM UTC

Hi Harry,

In our ASP.NET MVC Treegrid, we have rendered all the html elements in clientside and we have passed the data to the control from serverside to clientside as Json data by serializing it. And we have used the defaultMaxJsonLengthvalue (2097152characters, which is equivalent to 4MB of Unicode string data) of the JavaScriptSerializer which is a fixed universal standard length for serializing the data, in our implementation.

So we have to create a custom serializer to serialize the data Source if the data exceeds its limit, this can be done as follows.

using Newtonsoft;

using Syncfusion.JavaScript.Shared.Serializer;


public ActionResult Index() {

        var DataSource = GanttDataSource.GetData();

        DataManagerConverter.Serializer = new DMSerial();

        ViewBag.datasource = DataSource;

        return View();



public class DMSerial: IDataSourceSerializer {

    public string Serialize(object obj) {

        var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

        return str;



We have also prepared a sample based on this and you can find the sample under the following location:

Sample: http://www.syncfusion.com/downloads/support/forum/119571/ze/LargeData888429426

Please let us know if you need further assistance on this.


Mahalakshmi K.

Harry Zheng
Replied On July 10, 2015 01:59 PM UTC

Hi Mahalakshmi,

Thank you for the solution. It works great!



Mahalakshmi Karthikeyan [Syncfusion]
Replied On July 13, 2015 05:46 PM UTC

Hi Harry,
Thanks for the update. We are happy to assist you.
Please let us know if you need more information on this.
Mahalakshmi K.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon