Can anyone help me how I can able to create a JSON object in JavaScript without any concate strings? Here is my JSON data and my JavaScript:
{
"employees": [
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}
]
}
JavaScript:
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; });
}
Any help would be appreciated.