title: Create JSON object dynamically via JavaScript (Without concate strings)
body: <p>I have this JSON data:</p>
  
  <pre><code>{
      "employees": [
          {
              "firstName": "John",
              "lastName": "Doe"
          },
          {
              "firstName": "Anna",
              "lastName": "Smith"
          },
          {
              "firstName": "Peter",
              "lastName": "Jones"
          }
      ]
  }
  </code></pre>
  
  <p>Suppose I don't know how many columns and rows of employees I have, how do I create this object in JavaScript (Without concate strings)? Assume that I get each row in "onGeneratedRow" method, and I need to push each column (firstName, lastName) to the '{}' brackets.</p>
  
  <pre><code>var viewData = { 
      employees : [] 
  };
  
  var rowNum = -1; 
  
  function onGeneratedRow(columnsResult)
  {
      rowNum = rowNum + 1;
      viewData.employees.push({});    
      columnsResult.forEach(function(column) {                  
      var columnName = column.metadata.colName;
      viewData.employees[rowNum][columnName] = column.value;  });
  }
  </code></pre>