Created
May 28, 2013 14:16
-
-
Save yawboakye/5663065 to your computer and use it in GitHub Desktop.
Tiny recursive JSON traversal tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple json traversal tool. *needs improvement* | |
var json = function (data, padding) { | |
var p = ''; | |
if ( Object.prototype.toString.call(data) !== '[object Object]' ) { | |
for ( var i = 0; i < padding; ++i ) p += ' '; | |
console.log(p + data) | |
return | |
} else { | |
for ( var prop in data ) { | |
json(data[prop], padding + 2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment