Skip to content

Instantly share code, notes, and snippets.

@asssis
Last active February 1, 2019 14:21
Show Gist options
  • Save asssis/57c0f4e2a47498c264690a0d83c27212 to your computer and use it in GitHub Desktop.
Save asssis/57c0f4e2a47498c264690a0d83c27212 to your computer and use it in GitHub Desktop.
function json_to_table(json)
{
type = jQuery.type(json);
if(jQuery.type(json) == "array") {
table = "<table>";
table += "<tr>";
table += "<thead>"
$.each(json[0], function(key, value){
table += "<th>"
table += key
table += "</th>"
});
table += "</tr>";
table += "</thead>";
table += "<tbody>"
table += "<tr>";
$.each(json, function(key, value) {
table += "<tr>";
$.each(value, function(key, value)
{
table += "<td>"
table += value
table += "</td>"
});
table += "</tr>";
});
table += "</table>";
}
return table
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment