Looking for some assistance here. I have a function that returns the following JSON.stringify output in JavaScript:
{"tablerows":[{"colone":"test","colthree:":"testf","row:0},{"colone":"testd","row":1}]}
However, I am aiming to achieve a structure with an additional level for each row, like this:
row0
row0.colone: test
row0.colthree: testf
row1
row1.colone: testd
for (var i = 0; i < rowCount; i++) {
var row = table.rows[i];
var currentrowcellcount = $('td', row).length;
if (currentrowcellcount == 4) {
var colone = row.cells[0].childNodes[0].childNodes [0].innerHTML;
var coltwo = row.cells[1].childNodes[0].childNodes[0].innerHTML;
var colthree = row.cells[2].childNodes[0].childNodes[0].innerHTML;
tablerow = {
'colone': colone,
'coltwo': coltwo,
'colthree': colthree
}
container.tablerows.push(tablerow);
container.tablerows[i].row = i;
}
else if (currentrowcellcount == 2) {
var fieldnameone = row.cells[0].childNodes[0].childNodes[0].innerHTML;
}
}
$('#SuccessUpdate').fadeIn(500).delay(500).fadeOut(500);
alert(JSON.stringify(container));