how to read and show json 2d array using getJSON?

JSON file example is..

[{"name" : "메뉴1", "permission" : "1", "link" : "http://naver.com"},
{"name" : "메뉴2", "permission" : "2", "link" : "http://daum.net", "sub" : [
    {"name" : "메뉴2-1", "permission" : "1", "link" : "http://google.com"},
    {"name" : "메뉴2-2", "permission" : "1", "link" : "http://yahoo.com"}
]}]

I want to put a secondary menu at the bottom of the primary menu. I know how to show 1d array but I can't show 2d array. Please help me.

    <script>
$(document).ready(function() {
  {
    $.getJSON('./inc/menu.json', function(data) {
      var html = '';
      html += '<ul>';
      $.each(data, function(entryIndex, entry) {
          html += '<li><a href=' + entry.link + ' title=' + entry.permission  + '>' + entry.name + '</a></li>';
      });
      html += '</ul>';
      console.log(html);
      $("nav").html(html);
    });
    return false;
  }
});
</script>


#jquery #json #javascript

2 Likes47.50 GEEK