I have code that can do this in javascript, although for arrays it is checking differences by index so you would need to be aware of that. I would think this code snippet could be adapted to run in a script snap and get the output you desire. I put in the two objects from your example into the little utility code I had and it found the differences, would just need to modify the output formatting to what you specified.
Function -
self.internalFindDifference = function(obj1, obj2, parent, accum) {
var result = accum || { "changes": [] };
for (key in obj1) {
if (!obj2.hasOwnProperty(key)) {
result.changes.push({ "field": parent ? parent + "." + key : key, "type": "add", "value": obj1[key] });
} else if (!_.isEqual(obj1[key],obj2[key]) && typeof obj1[key] == 'object' && typeof obj2[key] == 'object') {
var newParent = parent ? parent + "." + key : key;
arguments.callee(obj1[key], obj2[key], newParent, result);
} else if (!_.isEqual(obj1[key], obj2[key])) {
result.changes.push({ "field": parent ? parent + "." + key : key, "type": "change", "fromValue": obj2[key], "toValue": obj1[key] });
}
}
for (key in obj2) {
if (!obj1.hasOwnProperty(key)) {
result.changes.push({ "field": parent ? parent + "." + key : key, "type": "delete", "fromValue": obj2[key] });
}
}
return result;
}
Example calling code -
var result = self.internalFindDifference(obj1, obj2, null, null);
Console.log(JSON.stringify(result, null, 4));