title: output correct JSON response
body: <p>I'm generating some JSON output with the following code:</p>
  
  <pre><code>    generator = JSON.createGenerator(true);
      generator.writeStartObject();
      generator.writeFieldName('employees');
      generator.writeStartArray();
      for(User u : getUsers()) {
          generator.writeStartObject();
          generator.writeStringField('key', u.Id);
          generator.writeStringField('nickname', u.CommunityNickname);
          generator.writeStringField('lastname', u.LastName);
          if(u.Region__c != null) {
              generator.writeStringField('region', u.Region__c);
          }
          else {
              generator.writeStringField('region', '');
          }
          if(u.Home_District__c != null) {
              generator.writeStringField('district', u.Home_District__c);
          }
          else {
              generator.writeStringField('district', '');
          }
          if(u.Home_District__c != null) {
              generator.writeStringField('pack', u.Pack__c);
          }
          else {
              generator.writeStringField('pack', '');
          }
          generator.writeStringField('employee', u.Name);
          generator.writeEndObject();
      }
      generator.writeEndArray();
      generator.writeFieldName('events');
      generator.writeStartArray();
      for(Site_Visit__c sv : getSiteVisits()) {
          generator.writeStartObject();
          if(sv.Status__c.toLowercase() == 'scheduled') {
              generator.writeFieldName('assigned');
              generator.writeStartObject();
              if(sv.Intended_Start_Date_Time__c != null) generator.writeStringField('start_date', String.valueOf(sv.Intended_Start_Date_Time__c));    
              if(sv.Estimated_Completion_Date_Time__c != null) generator.writeStringField('end_date', String.valueOf(sv.Estimated_Completion_Date_Time__c));
              generator.writeStringField('text', String.valueOf(sv.Name));
              if(sv.Assigned_Employee__c != null) generator.writeStringField('section_id', String.valueOf(sv.Assigned_Employee__c));
              generator.writeStringField('id', String.valueOf(sv.Id));
              generator.writeStringField('color', String.valueOf('#ffffff'));
              generator.writeStringField('textColor', String.valueOf('#000000'));
              generator.writeEndObject(); 
          }
          if(sv.Status__c.toLowercase() == 'unassigned') {
              generator.writeFieldName('unassigned'); 
              generator.writeStartObject();
              if(sv.Intended_Start_Date_Time__c != null) generator.writeStringField('start_date', String.valueOf(sv.Intended_Start_Date_Time__c));    
              if(sv.Estimated_Completion_Date_Time__c != null) generator.writeStringField('end_date', String.valueOf(sv.Estimated_Completion_Date_Time__c));
              generator.writeStringField('text', String.valueOf(sv.Name));
              generator.writeStringField('id', String.valueOf(sv.Id));
              generator.writeStringField('color', String.valueOf('#ffffff'));
              generator.writeStringField('textColor', String.valueOf('#000000'));
              generator.writeStringField('woNumber', String.valueOf(sv.Work_Order__r.Name));
              generator.writeStringField('woType', String.valueOf(sv.Work_Order__r.Work_Order_Type__c));
              generator.writeStringField('customer', String.valueOf(sv.Work_Order__r.Customer__c));
              generator.writeEndObject();             
          }
          generator.writeEndObject(); 
      }
      generator.writeEndArray();
      generator.writeEndObject();
  </code></pre>
  
  <p>The current output is like the following:</p>
  
  <pre><code>{
  employees:
      employee
      employee
  events:
      unassigned:
          event
      unassigned:
          event
      assigned:
          event
      assigned:
          event
      (empty object?)
      (empty object?)
  }
  </code></pre>
  
  <p>I need it to be like this:</p>
  
  <pre><code>{
  employees:
      employee
      employee
  events:
      unassigned:
          event
          event
      assigned:
          event
          event
  }
  </code></pre>
  
  <p>Events is an object (not an array) that has two field: assigned and unassigned.  Each of those fields is an array of events that match their description.</p>
  
  <p>Thanks for any help.</p>