Skip to content

Instantly share code, notes, and snippets.

@biswarupadhikari
Created February 1, 2013 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biswarupadhikari/4689978 to your computer and use it in GitHub Desktop.
Save biswarupadhikari/4689978 to your computer and use it in GitHub Desktop.
Generate Table from JSON Object
function createTableFromJSON(jsonObj){
var table='';
var tableHeader=jsonObj[0];
table+='<table>';
table+='<thead><tr>';
for(index in tableHeader){
table+='<th>'+index+'</th>';
}
table+='</tr></thead>';
table+='<tbody>';
for(i=0;i<jsonObj.length;i++){
table+='<tr>';
var obj=jsonObj[i];
for(index in obj){
value = obj[index];
table+='<td>'+value+'</td>';
}
table+='</tr>';
}
table+='</tbody>';
table+='</table>';
return table;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment