Firstly, what you have is not valid JSON. You use semicolons instead of commas. Also in a JSON string, all keys have to be surrounded by quotes (which is not the case in your example).
Your first code step would be to convert the JSON string to an object, using
JSON.parse
. Then you can use
Object.keys
to get all keys from the first object, and you can loop over these keys to see the difference in values in the two objects.
var jsonString1 = '{"Name":"ABC","Work":"Programmer","State":"123"}';
var jsonString2 = '{"Name":"XYZ","Work":"Engineer","State":"456"}';
var jsonObject1 = JSON.parse(jsonString1);
var jsonObject2 = JSON.parse(jsonString2);
var keys = Object.keys(jsonObject1);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (jsonObject1[key] != jsonObject2[key]) {
console.log(key + " value changed from '" + jsonObject1[key] + "' to '" + jsonObject2[key] + "'");
}
}