I am trying to find the difference between two JSON object property name in typescript or JavaScript. When we comparing the two JSON object how to find the which group name object values is different. Example: From my code group name B6006 is different, So how to get that group name in JavaScript or typescript. If anyone knows please help to find the solutions.
app.component.ts:
jsonobj1 = [
{
group_name: 'A6006',
one_group: ['C85000_ZK', 'C95000_Z'],
selected: [],
two_group: ['FPC6516_A'],
},
{
group_name: 'B6006',
one_group: ['Z6800_BB', 'G6800_D'],
selected: [],
two_group: ['P6516_AB'],
},
];
jsonobj2 = [
{
group_name: 'A6006',
one_group: ['C22000_ZK', 'C44000_Z'],
selected: [],
two_group: ['FPC9916_A'],
},
{
group_name: 'B6006',
one_group: ['Z6800_BB', 'G9900_D'],
selected: [],
two_group: ['P6516_AB'],
},
];
ngOnInit() {
if (JSON.stringify(this.jsonobj1) === JSON.stringify(this.jsonobj2)) {
console.log('Both json object is same');
} else {
console.log('Both json object is not same. This'+propertyname????????+ 'value are different');
}
}
Demo: https://stackblitz.com/edit/angular-ivy-dbbfud?file=src%2Fapp%2Fapp.component.ts