1π
β
Is JSON.stringify()
the wrong function to be using?
yes because a valid JSON is converted into a JSON string.
Instead just push the object you want to have in the array:
for (i in result) {
var foo = {value: result[i].total, label: result[i].subcategory}
pieData.push(foo);
}
Source:stackexchange.com