title: Populate switch case data using json
body: <p>I'm trying to add switch cases using json. How can I populate the data?</p>
  
  <p>This is the expected output:</p>
  
  <pre><code>$(".custom-menu li").click(function(){
       switch($(this).attr("data-action")) {
       // A case for each action.
           case "Science": $('.abc:eq(0)').trigger('click',['Zoology']); break;
           case "Science": $('.abc:eq(1)').trigger('click',['Botany']); break;
           case "Maths": $('.abc:eq(2)').trigger('click',['Geometry']); break;
       }
  });
  </code></pre>
  
  <p>This is the structure:</p>
  
  <pre><code>$(".custom-menu li").click(function(){
       switch($(this).attr("data-action")) {
         //looking to populate data here
       }
  });
  </code></pre>
  
  <p>jQ</p>
  
  <pre><code>var val;
  $.ajax({url: 'subjects.json'}).done(function(d) {
      val = d;
      $.each(val, function(i, su) {
        $('case "'+su[0]+'": $('.content:eq(0)').trigger('click',['+su[1]+']); break;')
        .appendTo('data-action'); //How to refer $(this).attr("data-action")
      });
  });
  </code></pre>
  
  <p>json:</p>
  
  <pre><code>[ [ "Science", "Zoology"],
  [ "Science", "Botany"],
  [ "Maths", "Geometry"] ]
  </code></pre>