MVC 4 ASP.NET Web API application :
I have a JSON array of form :
var json = "{
'mapset':
[
{
'id': '1',
'key': 'key1',
'value': 'value1',
'timestamp': '2014-02-12T08:50:54.594Z'
},
{
'id': '2',
'key': 'key2',
'value': 'value2',
'timestamp': '2014-02-12T08:50:54.594Z'
},
]
}";
dynamic data = System.Web.Helpers.JSON.decode(json);
For array with 10K elements of ~1K bytes each, JSON.Decode()
works like a charm.
For 100K elements fails with error :
System.ArgumentException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.Parameter name: input at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) at System.Web.Helpers.Json.Decode(String value)
How can I set the limit higher ?
I am aware of the other post regarding this topic :
Can I set an unlimited length for maxJsonLength in web.config?
However the answers provided there do not solve my specific problem.
I am directly using JSON.Decode()
within an MVC4 app and so modification of web.config
settings will not apply. And JSON.Decode()
performs deserialization of a JSON string to a .NET JSON object ( not serialization of a .NET JSON object to a JSON string ).