I am trying to convert this HTML table:

Code:
Try below approach for n columns
DEMO: http://jsfiddle.net/ptVDm/7/
var tblhdr = $('table#students th').map(function () {
return $(this).text();
}).get();
console.log(tblhdr);
var tbl = $('table#students tbody tr').map(function(idx, el) {
var td = $(el).find('td');
var obj = {id: idx+1};
//Can work on number of columns
for (var i = 0; i < tblhdr.length; i++) {
obj[tblhdr[i]] = td.eq(i).text();
}
return obj;
}).get();
console.log(tbl);