title: How to serialize a large JSON object directly to HttpResponseMessage stream?
body: <p>Is there any way to stream a large JSON object directly to the HttpResponseMessage stream?</p>
  
  <p>Here is my existing code:</p>
  
  <pre><code>        Dictionary&lt;string,string&gt; hugeObject = new Dictionary&lt;string,string&gt;();
          // fill with 100,000 key/values.  Each string is 32 chars.
          HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
          response.Content = new StringContent(
              content: JsonConvert.SerializeObject(hugeObject),
              encoding: Encoding.UTF8,
              mediaType: "application/json");
  </code></pre>
  
  <p>Which works fine for smaller objects.  However, the process of calling JsonConvert.SerializeObject() to convert the object into a string is causing problematic memory spikes for large objects.</p>
  
  <p>I want to do the equivalent of <a href="http://www.newtonsoft.com/json/help/html/performance.htm" rel="nofollow">what's described here for deserialization</a>.</p>