title: How to map JSON data to a class
body: <p>I created a ES6 class by <a href="https://github.com/babel/babel" rel="noreferrer">Babel</a> and I want to map JSON data which is gotten from a server to the ES6 class. <br>
  Is there anything common way to do that?</p>
  
  <p><strong>User.js</strong></p>
  
  <pre><code>export default class User {
    constructor() {
      this.firstName;
      this.lastName;
      this.sex;
    }
  }
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>import User from "./classes/User";
  
  var data = JSON.parse(req.responseText);
  console.log(data.firstname); //Bob
  //now...just set data one by one?
  </code></pre>