Last active
February 1, 2019 14:21
-
-
Save asssis/57c0f4e2a47498c264690a0d83c27212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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