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. Image for the cookie policy date
close icon

URGENT - ParseModel - JSON - MAxLength Error

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.

5 Replies

SG Shyam G Syncfusion Team September 19, 2017 01:54 PM UTC

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 



KA Karthick September 20, 2017 11:34 AM UTC

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. 



SG Shyam G Syncfusion Team September 21, 2017 05:35 AM UTC

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



SY syntax replied to Karthick December 22, 2017 09:50 PM UTC

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.


SG Shyam G Syncfusion Team December 26, 2017 04:56 AM UTC

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 


Loader.
Live Chat Icon For mobile
Up arrow icon