title: get value from json when passed key is a variable
body: <p>I am creating a list by fetching values from a JSON file. It is a nested JSON and the list items are- "Thriller","Fiction" which are basically keys for the next level.
  on click of the item I'm passing its name(i.e. Thriller/fiction) to another function...
  <strong>var</strong> val = thriller.</p>
  
  <p>Now I need to fetch the value(i.e. "book" &amp; bookname) corresponding to the passed key in this new function. I'm not able to do so using dot operator-
  <strong><em>data.library.val</em></strong> not working..</p>
  
  <p>If anybody has worked on something similar..please help..</p>
  
  <p><strong>JSON:</strong></p>
  
  <pre><code>{ "library": [
  
      {
          "Thriller": [
              { "book": "ABC" },
              { "book": "DEF" }
          ]
      },
      {
          "Fiction": [
              { "book": "GHI" },
              { "book": "JKL" }
          ]
      },]  }
  </code></pre>
  
  <p><strong>Code snippet:</strong></p>
  
  <pre><code>$.getJSON('resources/abc.json', function(data){
  
          var i = data.library;
          $("#menuList1").css('display','block');
          $(i).each(function(key, value){
              $.each(value, function(key, value){
                      console.log(key);
                      $("#menuList1").append('&lt;a href="#" id="'+key+'" onClick="createSubMenu(id);"&gt;'+key+'&lt;/a&gt;');
      });       
     });    });
  </code></pre>