An error is reported when deserializing or serializing using JSON JavaScriptSerializer. The length of the character exceeds the length of MaxJsonLength,

Source: Internet
Author: User

An error is reported when deserializing or serializing using JSON JavaScriptSerializer. The length of the character exceeds the length of MaxJsonLength,

Article reference: https://www.cnblogs.com/wangfuyou/p/6046307.html

1. The solution is to add the following nodes in web. config to <configuration>.

<System. web. extensions>
<Scripting>
<WebServices>
<JsonSerialization maxJsonLength = "1024000000" type = "codeph" text = "/codeph"/>
</WebServices>
</Scripting>
</System. web. extensions>

 

2.

1 RootObject ScriptDeserialize (string json) 2 {3 // the maximum length of the JSON string. The default length is 2097152 characters, which is equivalent to 4 MB of Unicode string data. 4 // js. maxJsonLength = 2097152; 5 js. maxJsonLength = 10240000; 6 JavaScriptSerializer jsseria = new JavaScriptSerializer (); 7 jsseria. maxJsonLength = Int32.MaxValue; 8 return js. deserialize <RootObject> (json); 9}

 

Tip: you cannot directly modify the json size because the default value is used in the built-in JsonResult code of the MVC framework when using JavaScriptSerializer. If the value is not read from maxJsonLength, this configuration is ignored.

So we need to rewrite it to overwrite the original configuration.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.