Why does this example show only parent parent properties when using JSON.stringify ?
how can I get around it ?
class Parent {
id: string;
name: string;
children?: Child[]
constructor(id:string ,name: string){
this.id = id
this.name = name
}
}
class Child {
child_id: string;
child_name: string;
constructor(id: string,name: string){
this.child_id = id
this.child_name = name;
}
}
const p = new Parent("p1","Parent 1")
const c1 = new Child("c1","Child 1")
p.children?.push(c1);
console.log(JSON.stringify(p))