the best I found for this purpose is the class-transformer. github.com/typestack/class-transformer
That's how you use it:
Some class:
export class Foo {
name: string;
@Type(() => Bar)
bar: Bar;
public someFunction = (test: string): boolean => {
...
}
}
import { plainToClass } from 'class-transformer';
export class SomeService {
anyFunction() {
u = plainToClass(Foo, JSONobj);
}
If you use the @Type decorator nested properties will be created, too.