Skip to content

Instantly share code, notes, and snippets.

@tfaris
Last active December 1, 2015 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfaris/711d6c212e72464f15b0 to your computer and use it in GitHub Desktop.
Save tfaris/711d6c212e72464f15b0 to your computer and use it in GitHub Desktop.
Javascript function that logs JSON changes (not additions or deletions) found using http://tlrobinson.net/projects/javascript-fun/jsondiff to the console.
function printJsonDiff(ch){
for (var i in ch){
var el = ch[i],
header;
if (el.parentNode.parentNode.firstChild.firstElementChild && el.parentNode.parentNode.firstChild.firstElementChild.innerText === "(array)"){
header = el.parentNode.parentNode.parentNode.parentNode.firstChild.innerText + " :: " + el.parentNode.parentNode.firstChild.innerText;
}
else{
header = el.parentNode.parentNode.firstChild.innerText;
}
console.debug(header + " :: " + el.innerText);
}
}
printJsonDiff(document.getElementsByClassName("changed"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment