title: How to use a JavaScript to load and parse a static JSON file in the server
body: <p>I'm just starting to use javascript and json.</p>
  
  <p>I need to read data (getInformation function) from a json file when processing an event in a javascript function. So I need it to be synchronic. I don't know if I am missing something in the code, or if I have to create an Request and handle the callback, or if I need to import additional javascript to use json. Because I don't know how to make it work. It doesn't work because at the end the array is empty. Any help is aprreciated.</p>
  
  <p>The json file:</p>
  
  <pre><code>{"Users": [
      {"Name": "Jane",
          "Points": 67,
          "age": 23},
      {
          "Name": "Sam",
          "Points": 65,
          "age": 21}
  ]} 
  </code></pre>
  
  <p>Option 1 - Function called by another function which is processing an event:</p>
  
  <pre><code>var getInformation = function() 
  {
      var path = "./data/users.json";
      var informationArray= [];
      console.log("Loading ....");
      $.getJSON(path, function(data) 
      {
          $.each(data, function(key, val) 
          {
              informationArray.push(key + '-' + val);
          });
      }); 
      return informationArray; 
  }
  </code></pre>
  
  <p>Option 2 - Function called by another function which is processing an event:</p>
  
  <pre><code>var getInformation = function() { 
  var path = "./data/users.json";
  var informationArray= [];
  $.ajax({
           url: path,
           async: false,
           dataType: 'json',
           success: function(response) {
           $.each(response.items,
           function(item) {
           informationArray.push(item);
           });
           informationArray.push("success");
           }
           }); 
     return informationArray; }
  </code></pre>
  
  <p>I have seen the following thread and tried what is there but doens't work for me. I would like to know where is the problem in my code or if require any special configuration.</p>
  
  <p>Thread: <a href="https://stackoverflow.com/questions/933713/is-there-a-version-of-getjson-that-doesnt-use-a-call-back">Is there a version of $getJSON that doesn&#39;t use a call back?</a></p>