I'm new to jQuery!
Is there a way to convert table element data to JSON? see sample image below.
The JSON result was on the #result
div.
I'm new to jQuery!
Is there a way to convert table element data to JSON? see sample image below.
The JSON result was on the #result
div.
var arr = $('tr').map(function () {
var o = {
"apvhdrid": this.parentNode.parentNode.dataset.apvhdrid,
"id": this.dataset.id
};
$('td', this).each(function () {
for (key in this.dataset) {
o[key] = this.dataset[key];
}
})
return o;
}).get();
$('#result').text(JSON.stringify(arr));