json-typescript-mapper(https://www.npmjs.com/package/json-typescript-mapper)
Step 1: Install package:
npm install reflect-metadata --save
npm install json-typescript-mapper --save
Step 2: Define your class:
class Student {
@JsonProperty('name') //Decorator with Json property name]
fullName:string;
constructor() {
this.fullName = undefined; //Setting a default value in the constructor is must
}
}
Step 3: Import reflect-metadata Add the below import statement at the top of app.component.ts
import 'reflect-metadata';
Step 4: Deserialize: deserialize(, );
import { deserialize } from 'json-typescript-mapper';
var person = deserialize(Person, json);