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.

URGENT - ParseModel - JSON - MAxLength Error

Thread ID:

Created:

Updated:

Platform:

Replies:

132746 Sep 19,2017 05:38 AM Dec 25,2017 11:56 PM ASP.NET MVC 5
loading
Tags: Diagram
Karthick
Asked On September 19, 2017 05:38 AM

Hi, I am trying to bind a JSON to DiagramProperties using ParseModel and getting "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property" error. Here is my code. 

StreamReader oReader = new StreamReader(@"D:\Diagram\Syncfusion-Diagram-JSON\BASE.txt");
string szJsonString = oReader.ReadToEnd().Trim();
 DiagramProperties model = new DiagramProperties();
 model.ParseModel(szJsonString);

I am using this code in MVC controller. Can someone help me quick? I have a deployment tonight and need to resolve this? I tried using DMSerialize class but didnt work or I am not sure if I implemented wrongly. Please help.

Shyam G [Syncfusion]
Replied On September 19, 2017 09:54 AM

Hi Karthick, 
 
By default, the entire diagram model properties will be serialized. So only the JSON string length exceeds the maximum value. Please refer to the code example in which we have removed the property which is set as an null value after saving the diagram. please refer to the sample below. However currently we don’t have support to serialize the particular/user defined diagram’s model properties. We have already logged “Need to provide an option to serialize the user defined diagram model’s properties” as a feature and provided the feature description below.  We have planned to implement this feature in our volume 4,2017 release. We will let you know once the volume 4,2017 release is rolled out.  
 
Code example: 
 
      var diagram = $("#diagram").ejDiagram("instance"); 
        //save the diagram 
       var saveDiagram = diagram.save(); 
         for (var prop in saveDiagram) { 
                 //delete the null value property 
         if (saveDiagram[prop] === null) { 
                     delete saveDiagram[prop]; 
            } 
          } 
 
Also please use the below code example in the web.config file. Please refer to the below sample for further reference. 
 
Code example: 
<system.web.extensions> 
    <scripting> 
      <webServices> 
        <jsonSerialization maxJsonLength="2147483644"/> 
      </webServices> 
    </scripting> 
  </system.web.extensions> 
 
 
Regards, 
Shyam G 


Karthick
Replied On September 20, 2017 07:34 AM

Thank you Shyam for the direction. Also, I noticed that historical data with the changes are logged as part of the JSON that increases the size. I deleted it and the JSON size has come down to 1MB from 5MB. Then the ParseModel line worked well. 


Shyam G [Syncfusion]
Replied On September 21, 2017 01:35 AM

Hi Karthick, 
Please let us know if you need further assistance on this. 
Regards, 
Shyam G 


syntax
Replied On December 22, 2017 04:50 PM

Thank you Shyam for the direction. Also, I noticed that historical data with the changes are logged as part of the JSON that increases the size. I deleted it and the JSON size has come down to 1MB from 5MB. Then the ParseModel line worked well. 


Hi Kartchik,

I am running into the same problem. Can you please share what you have done in order to bring down the size of the JSON? Where do you delete the historical data?

Thank you in advance.

Shyam G [Syncfusion]
Replied On December 25, 2017 11:56 PM

Hi Syntax, 
 
Could you please upgrade to the latest version 15.4.0.17? if yes, we have implemented the feature “Need to provide an option to serialize the user defined diagram model’s properties” in our Essential Studio 2017 Volume 4 Release v15.4.0.17 is rolled out and is available for download under the following link 
                            
 
In this feature, if we set diagram model’s serializationSettings preventDefaultValues property as true, then the user defined model properties alone will be saved while saving it using diagram save method. Please refer to the code example and drafted documentation below. 
 
Code example: 
DiagramProperties model = new DiagramProperties(); 
// serialize user defined model properties when preventDefaultValues is true.   
 model.SerializationSettings.PreventDefaultValues = true; 
 
  
please let us know if any concerns. 
 
Regards, 
Shyam G 


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.

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.

;