I have a JSON object like below,
export class MyComponent {
@Input() cityinfoJSON; // this JSON comes as following from parent component as below
let cityinfoJSON =
{
"id": 0,
"name": "",
"description": "",
"address": {
"city": "NY",
"zipcodes": [],
"countyList": {
"countyName": '',
"countyzip": "claim_type",
"countyPlaceVerified": "N"
},
"sort": []
}
}
let OriginalJSON
ngOninit() {
// I am creating an unmodified version of it using
this.OriginalJSON = JSON.parse(JSON.stringify(cityinfoJSON));
}
}
When cityinfoJSON’s countyPlaceVerified is modified to ‘Y’, I don’t expect OriginalJSON’S countyPlaceVerified to change. It is also getting changed to Y’. This shouldn’t happen, as I am deep copying it. How can we achieve as OriginalJSON remains unchanged.