Compare two JSON Objects and validate if data mismatched using jQuery. I need to select records in two tables and compare selected column(firstName) values are same only will allow for further validations. If firstname is mismatched have to show alert like data is mismatched. I tried with below code, please suggest me the issue..
const obj1Keys = Object.keys(jsonData1);
const obj1Values = Object.values(jsonData1);
const obj2Keys = Object.keys(jsonData2);
const obj2Values = Object.values(jsonData2);
for (let i = 0; i < obj1Keys.length; i++) {
for (let j = 0; j < obj2Keys.length; j++) {
if (obj1Keys[i] === obj2Keys[j]) {
if (obj1Values[2] !== obj2Values[2]) {
alert("data mismatched");
}
}
}
}
}
Eg: firstTable : Toto and second table Toto, Toto >> allowed. If any mismatched have to show alert.
Have to validate 1 to many and many to 1.