title: How to create JSON Array Inside JSON object using FOR JSON SQL Server 2016
body: <p>How to create JSON Array Inside JSON object using FOR JSON SQL Server 2016 (TABLE to JSON)<br>
  Here is my query:</p>
  
  <pre><code>SELECT   
  m.MeetingId AS tblMeeting_MeetingId,  
  m.Attended AS tblMeeting_Attended, 
  m3.CompanyId AS tblMeetingAttendants_CompanyId, 
  m3.MeetingAttendantsId AS tblMeetingAttendants_AttendantNameWithTitle, 
  m4.UserId AS tblMeetingAttendees_UserId, 
  m5.BrokerId AS tblMeetingBroker_BrokerId 
  FROM Bv.tblMeeting m 
  LEFT JOIN Bv.tblMeetingAttendants m3 ON m.MeetingId = m3.MeetingId  
  LEFT JOIN Bv.tblMeetingAttendees m4 ON m.MeetingId = m4.MeetingId  
  LEFT JOIN Bv.tblMeetingBroker m5 ON m.MeetingId = m5.MeetingId  
  WHERE m.MeetingId = 739 
  FOR JSON AUTO, INCLUDE_NULL_VALUES
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BoG5M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BoG5M.png" alt="enter image description here"></a></p>
  
  <p>Above query gives me result like this:</p>
  
  <pre><code>[
  {
      "tblMeeting_MeetingId": 739,
      "tblMeeting_Attended": false,
      "tblMeeting_MeetingSubject": " Benchmark China Internet Analyst",
      "m3": [
          {
              "tblMeetingAttendants_CompanyId": 83,
              "tblMeetingAttendants_AttendantNameWithTitle": 499,
              "m4": [
                  {
                      "tblMeetingAttendees_UserId": null,
                      "m5": [
                          {
                              "tblMeetingBroker_BrokerId": 275
                          }
                      ]
                  }
              ]
          },
          {
              "tblMeetingAttendants_CompanyId": 83,
              "tblMeetingAttendants_AttendantNameWithTitle": 500,
              "m4": [
                  {
                      "tblMeetingAttendees_UserId": null,
                      "m5": [
                          {
                              "tblMeetingBroker_BrokerId": 275
                          }
                      ]
                  }
              ]
          },
          {
              "tblMeetingAttendants_CompanyId": 83,
              "tblMeetingAttendants_AttendantNameWithTitle": 501,
              "m4": [
                  {
                      "tblMeetingAttendees_UserId": null,
                      "m5": [
                          {
                              "tblMeetingBroker_BrokerId": 275
                          }
                      ]
                  }
              ]
          }
      ]
  }
  ]
  </code></pre>
  
  <p>But i want result like this</p>
  
  <pre><code>[
  {
      "tblMeeting_MeetingId": 739,
      "tblMeeting_Attended": false,
      "tblMeeting_MeetingSubject": " Benchmark China Internet Analyst",
      "tblMeetingAttendants_AttendantNameWithTitle": [499,500,501],
      "tblMeetingAttendees_UserId": null,
      "tblMeetingBroker_BrokerId": 275
  }
  ]
  </code></pre>
  
  <p>Please reply as soon as possible<br>
  Thanks in advance.</p>