I understand there are a ton of solutions to Encoding a large JSON string from an MVC point of view, and returning this from a controller.
What I cannot find, is a situation where I am decoding a large JSON string to an object in a non-MVC class library. I reach a certain size where I get the error:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property
This is using Json.Decode found in System.Web.Helpers
Example:
Say I have a class:
public class MyClass
{
public string id {get;set;}
public string name {get;set;}
}
And getting a rather large result from an external API request , I decode like so:
var result = Json.Decode<MyClass[]>(reponse);
Now, I have the ability to limit the number of returned records from the API request, but this doesn't help to show all the results available.
I have looked at all the solution on Stackoverflow I could find in regards to this error, but they all seem to involve serialization in an MVC environment.
(One example: Can I set an unlimited length for maxJsonLength in web.config?, tried all solutions)
Any thoughts?