I am trying to convert this HTML table:
Code:
See updated fiddle. The additional array map
is unnecessary because you are looking for a literal object for your JSON at this point.
var data = $('table#students tbody tr').map(function(index) {
var cols = $(this).find('td');
return {
id: index + 1,
name: cols[0].innerHTML, // use innerHTML
age: (cols[1].innerHTML + '') * 1, // parse int
grade: (cols[2].innerHTML + '') * 1 // parse int
};
}).get();