Skip to content

Instantly share code, notes, and snippets.

@wholypantalones
Created June 5, 2012 16:02
Show Gist options
  • Save wholypantalones/2875939 to your computer and use it in GitHub Desktop.
Save wholypantalones/2875939 to your computer and use it in GitHub Desktop.
JSON makeMenu()
function makeMenu(json) {
var html = "<ul>";
$.each(json,function(key,val){
html += "\n<li>";
if (typeof val === "object")
html += key +"\n" + makeMenu(val);
else
html += key + ": " + val;
html += "\n</li>";
});
html += "\n</ul>";
return html;
};
var menu = makeMenu(json);
$(menu).appendTo("#json");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment