I have a complex object that I want to serialize and deserialize and obtain an object of the same type.
let workflow = new Workflow();
console.log(`workflow is instanceof Workflow: ${workflow instanceof Workflow}`);
console.log(workflow);
let json = JSON.stringify(workflow);
console.log(json);
let workflow2 = JSON.parse(json) as Workflow;
console.log(workflow2);
console.log(`workflow2 is instanceof Workflow: ${workflow2 instanceof Workflow}`);
let workflow3: Workflow = JSON.parse(json) as Workflow;
console.log(workflow3);
console.log(`workflow3 is instanceof Workflow: ${workflow3 instanceof Workflow}`);
The console output is:
Is there an out of the box solution for this or I need to manually reinstantiate the complex object and set all of its properties?