Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Created July 10, 2011 03:10
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 OscarGodson/ec6929feaaa65bc3a245 to your computer and use it in GitHub Desktop.
Save OscarGodson/ec6929feaaa65bc3a245 to your computer and use it in GitHub Desktop.
var matchKey = function(k,v,j){
k = k || 'id'; //key
v = v || ''; //value
j = j || PAGES; //json
for(x in j){
if(j[x][k] == v){
return j[x];
}
if(j[x].subpages){
var result = matchKey(k,v,j[x].subpages);
if(result !== undefined){
return result;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment