Below is the code snippet I am using to generate an object:
var data = [];
data.push('{"headers":["Category 1","Value 1","Value 2"],"rows":[');
for (var i in results.data)
{
entry = '["'+ results.data[i].Type +'", '+ results.data[i].Amount +', '+ results.data[i].Discount+'],';
data.push(entry);
}
data.push(']}');
The desired object I want to create looks like this:
var my_data= {"headers":["Category 1","Value 1","Value 2"],"rows":[["Item A",174,23],["Item B",502,17],["Item C",242,37]...and so on]};
Is there a way to create the object directly without converting it to a string?