title: Serializing an array of objects one at a time with JSON.NET
body: <p>I try to serialize multiple items to json, and formats them as an array.</p>
  
  <p>It's event based, cause it's lot of data which could not be hold in memory as a whole collection. But I need to serialize each item into a file and format it like an array.</p>
  
  <pre><code>_jsonWriter = new JsonTextWriter(new StreamWriter("Output.json")));
  DataGatherer.ItemGathered += item =&gt;
  {
      _jsonSerializer.Serialize(_jsonWriter, item);
      _jsonWriter.Flush();
  };
  </code></pre>
  
  <p>Currently this outputs following:</p>
  
  <pre><code>{
    "Id": 218515,
    "Name": "A"
  }{
    "Id": 118647,
    "Name": "B"
  }
  </code></pre>
  
  <p>Since the serializer serializes each item as an object an does not know its an array.</p>
  
  <p>So how can I tell the JSON.Net serializer to handle each item as an item of an array and formats the data like so:</p>
  
  <pre><code>[{ "Id": 218515, "Name": "A"},{"Id": 118647,"Name": "B"}]
  </code></pre>
  
  <p>Thanks for any hints!</p>