I want to deserialize a JSON
Object in Typescript
. I have found this relevant question I would like to use the approach 4
of the accepted answer. However I am not sure if this would work in my case, since the object has member of arrays
of other objects and so do the objects in the array
as well. Moreover I would like to use a generic method/approach which deserializes the objects even if one does not know where the object dependencies end. The object structure looks like:
class Parent {
s: string;
x: number;
children : Array<Child1>
...
}
class Child1 {
t: string;
y: number;
children : Array<Child2>
...
}
class Child2 {
k: string;
z: number;
children : Array<Child3>;
...
}
...
How can I deserialize these type of objects? I would be satisfied even with an approach which takes the end of the object structure for granted.