title: Typescript : JSON to Typescript Object
body: <p>I just want to deserialise the JSON I am getting it from my server API.</p>
  
  <p>For most of the solutions mentioned out there (without using any third party library), it looks like the problem is solved.
  For example, the most up-voted answer on this SO thread : <a href="https://stackoverflow.com/a/41153231/1421881">HERE</a></p>
  
  <p>But the caveat which I observe is that the behaviour is not what I am expecting, when there is some extra property in json response which I am not expecting. </p>
  
  <p>Let's take an example : </p>
  
  <pre><code>class Person {
     id: number;
     name: string;
  }
  
  let jsonString = `{
     "id": 1,
     "name": "sumit",
     "age": 23
  }`;
  
  let person: Person = Object.assign(new Person(), JSON.parse(jsonString));
  
  console.log(Object.keys(person));
  console.log(JSON.stringify(person));
  </code></pre>
  
  <p>So when I work with "person" object later on, I expect that it contains only those properties which are mentioned in Person class, after all "person" is of type "Person".
  But surprisingly on serializing person, it contains those extra properties which are not in Person class. Here "age"</p>
  
  <p>Output for the above is :</p>
  
  <pre><code>["id", "name", "age"]
  {"id":1,"name":"sumit","age":23}
  </code></pre>
  
  <p>Now, how do I ensure that after the Deserialization, object "person" is not having any extra properties. </p>