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.
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:

Created:

Updated:

Platform:

Replies:

119571 Jul 9,2015 02:50 PM Jul 13,2015 01:46 PM ASP.NET MVC 3
loading
Tags: TreeGrid
Harry Zheng
Asked On July 9, 2015 02:50 PM

Hi,
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?
Thanks,

Harry

Mahalakshmi Karthikeyan [Syncfusion]
Replied On July 10, 2015 08:37 AM

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.

Regards,

Mahalakshmi K.


Harry Zheng
Replied On July 10, 2015 09:59 AM

Hi Mahalakshmi,

Thank you for the solution. It works great!

Regards,

Harry

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

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

CONFIRMATION

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.

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

;