title: Create a JavaScript Class from a JSON Object
body: <p>I have a JSON file which contains information data, and I get this data using AJAX using this function to fetch it.</p>
  
  <pre><code>function fetchJSONFile(callback) {
      var httpRequest = new XMLHttpRequest();
      httpRequest.onreadystatechange = function() {
          if (httpRequest.readyState === 4) {
              if (httpRequest.status === 200) {
                  var data = JSON.parse(httpRequest.responseText);
                  if (callback) callback(data);
              }
          }
      };
      httpRequest.open('GET', 'database.json');
      httpRequest.send(); 
  }
  </code></pre>
  
  <p>And I fetch it to assign it to the object of the current Class:</p>
  
  <pre><code>fetchJSONFile(function(data){ 
      employes = Object.assign(new Employes(), ...data.Employes);
      console.log(employes);
  })
  </code></pre>
  
  <p>The data within my JSON file is this: </p>
  
  <pre><code>{
  
  "Employes":[
          {
              "id": 1,
              "fullName": "Test Test"
          }
      ],
  "Infos":[
          {
              "id": 1,
              "address": "Test Test test test test",
              "employes": 1
          }
    ]
  }
  </code></pre>
  
  <p>My question is how to generate Classes automatically of each object type from the JSON file.</p>
  
  <p>Using my code like for example I want to generate <code>Employes</code> and <code>Infos</code> Classes automatically here without having to create them manually.</p>
  
  <pre><code>fetchJSONFile(function(data){ 
          employes = Object.assign(new Employes(), ...data.Employes); //Generate Classes automatically here from data type
          console.log(employes);
      })
  </code></pre>
  
  <p>Is there any solution?</p>