title: Typescript: Object to class
body: <p>Lets say I have a class C and an Instance of Object O (from JSON).</p>
  
  <pre><code>class C {
    str:string;
    num:number;
  }
  
  var o = JSON.parse ("{\"num\":123, \"str\":\"abc\"}");
  </code></pre>
  
  <p>Is there a way I can assign/initialize an instance of C with o and it checks for undefined values as well as for the type WITHOUT doing it by myself in a copy-constructor/function?</p>
  
  <p>I'd like to get an error or exception if a value is missing/undefined or the type does not match.</p>
  
  <p>Thanks!</p>