title: Deserialize JSON with large collection
body: <p>I am writing a console app that parses JSON data from an outside source. This is in C# using .NET 4.0 (the full version, not the client profile).
  I am attempting to use the System.Web.Script.Serialization.JavaScriptSerializer class to deserialize JSON data into an object, like this:</p>
  
  <pre><code>var targetObject = deserializer.Deserialize&lt;TargetObjectType&gt;(json);
  </code></pre>
  
  <p>Normally this works fine, but when the data contains a very large collection, I get this error: System.InvalidOperationException ("Operation is not valid due to the current state of the object.") I did some research and found this: <a href="http://support.microsoft.com/kb/2661403" rel="nofollow">http://support.microsoft.com/kb/2661403</a>. Basically, Microsoft limits the number of items as a security precaution.</p>
  
  <p>The way to override this is to add a record to Web.config as described in the support article, but in my case it doesn’t work. I did some research and found someone else with this problem here: <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx</a>.</p>
  
  <p>So my question is this: is there any way to use JavaScriptSerializer to deserialize a JSON object with a large collection in a console app?</p>
  
  <p>PLEASE NOTE: My team lead would prefer to not use any library other than Microsoft’s. THIS MEANS I CANNOT USE JSON.NET (AKA NEWTONSOFT), SO PLEASE DO NOT SUGGEST IT.</p>