title: How to parse a JSON object to a TypeScript Object
body: <p>I am currently trying to convert my received JSON Object into a TypeScript class with the same attributes and I cannot get it to work. What am I doing wrong?</p>
  
  <p><strong>Employee Class</strong></p>
  
  <pre><code>export class Employee{
      firstname: string;
      lastname: string;
      birthdate: Date;
      maxWorkHours: number;
      department: string;
      permissions: string;
      typeOfEmployee: string;
      note: string;
      lastUpdate: Date;
  }
  </code></pre>
  
  <p><strong>Employee String</strong></p>
  
  <pre><code>{
      "department": "&lt;anystring&gt;",
      "typeOfEmployee": "&lt;anystring&gt;",
      "firstname": "&lt;anystring&gt;",
      "lastname": "&lt;anystring&gt;",
      "birthdate": "&lt;anydate&gt;",
      "maxWorkHours": &lt;anynumber&gt;,
      "username": "&lt;anystring&gt;",
      "permissions": "&lt;anystring&gt;",
      "lastUpdate": "&lt;anydate&gt;"
      //I will add note later
  }
  </code></pre>
  
  <p><strong>My Attempt</strong></p>
  
  <pre><code>let e: Employee = new Employee();
  
  Object.assign(e, {
      "department": "&lt;anystring&gt;",
      "typeOfEmployee": "&lt;anystring&gt;",
      "firstname": "&lt;anystring&gt;",
      "lastname": "&lt;anystring&gt;",
      "birthdate": "&lt;anydate&gt;",
      "maxWorkHours": 3,
      "username": "&lt;anystring&gt;",
      "permissions": "&lt;anystring&gt;",
      "lastUpdate": "&lt;anydate&gt;"
  });
  
  console.log(e);
  </code></pre>
  
  <p><a href="https://www.typescriptlang.org/play/#src=class%20Employee%7B%0A%20%20%20%20firstname%3A%20string%3B%0A%20%20%20%20lastname%3A%20string%3B%0A%20%20%20%20birthdate%3A%20Date%3B%0A%20%20%20%20maxWorkHours%3A%20number%3B%0A%20%20%20%20department%3A%20string%3B%0A%20%20%20%20permissions%3A%20string%3B%0A%20%20%20%20typeOfEmployee%3A%20string%3B%0A%20%20%20%20note%3A%20string%3B%0A%20%20%20%20lastUpdate%3A%20Date%3B%0A%7D%0A%0Avar%20e%3A%20Employee%20%3D%20new%20Employee()%3B%0AObject.assign(e%2C%20%7B%0A%20%20%20%20%22department%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22typeOfEmployee%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22firstname%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22lastname%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22birthdate%22%3A%20%22%3Canydate%3E%22%2C%0A%20%20%20%20%22maxWorkHours%22%3A%203%2C%0A%20%20%20%20%22username%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22permissions%22%3A%20%22%3Canystring%3E%22%2C%0A%20%20%20%20%22lastUpdate%22%3A%20%22%3Canydate%3E%22%0A%7D)%3B%0Aconsole.log(e)%3B%0A" rel="noreferrer">Link to Typescript Playground</a></p>