title: How to get JSON array from file with getJSON?
body: <p>How could I get an array json of a json file with javascript and jquery</p>
  
  <p>I was triyng with the next code, with it doesnt work:</p>
  
  <pre><code>var questions = [];
  function getArray(){
      $.getJSON('questions.json', function (json) {
          for (var key in json) {
              if (json.hasOwnProperty(key)) {
                  var item = json[key];
                  questions.push({
                      Category: item.Category
                  });
              }
          }
          return questions;
      })
  }
  </code></pre>
  
  <p>this is the json file called: questions.json</p>
  
  <pre><code>{
  "Biology":{
      "Category":{
          "cell":{
              "question1":{
                  "que1":"What is the cell?"
              },
              "option1":{
                  "op1":"The cell is the basic structural and functional unit",
                  "op2":"is a fictional supervillain in Dragon Ball"
              },
              "answer1":"opt1"
          }
      }
  },
  "Astronomy":{
      "Category":{
          "Mars":{
              "question1":{
                  "que1":"How many moons does Mars?"
              },
              "option1":{
                  "op1":"5",
                  "op2":"2"
              },
              "answer1":"opt2"
          }
      }
  }
  }
  </code></pre>
  
  <p>I want to get an array with this format {Biology:{Category:{cell:{question1....}}}}</p>