Skip to content

Instantly share code, notes, and snippets.

@nelix
Forked from auser/gist:139933
Created July 3, 2009 15:34
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 nelix/140193 to your computer and use it in GitHub Desktop.
Save nelix/140193 to your computer and use it in GitHub Desktop.
## Function
traverse("object", obj, function(key, val) {console.log(key, val)});
## Call
function traverse(key, jsonObj, func) {
if( typeof jsonObj == "object" ){
$.each(jsonObj, function(k,v) {
traverse(k,v);
})
} else {
console.log(func);
// func.apply(key,jsonObj);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment