Created
November 18, 2011 02:43
-
-
Save asabaylus/1375412 to your computer and use it in GitHub Desktop.
Get GUID from User Name
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
var users = { | |
"a54bca8764-13bx5-8nln8s-0ga7d" : { | |
"name" : "Louise Voress", | |
"type" : "Committee", | |
"primarynominator" : "Dorrie Hutchison", | |
"reviewer1" : {"name" : "Tom Jones", "grade" : "A", "comments" : "", "status" : "Saved"}, | |
"reviewer2" : {"name" : "Lucy Young", "grade" : "A", "comments" : "", "status" : "Saved"}, | |
"adjudicator" : {"name" : "Steven Taylor", "recommendation" : "Yes", "comments" : "", "status" : "Saved"}, | |
"os" : [ | |
{"name" : "Kevin Joseph", "vote" : "Yes", "comments" : "", "status" : "Saved"}, | |
{"name" : "Matt Duncan", "vote" : "Yes", "comments" : "", "status" : "Saved"}, | |
{"name" : "Joanna Lit", "vote" : "Yes", "comments" : "", "status" : "Saved"} | |
], | |
"oschair" : {"decision" : "Yes", "comments" : "", "status" : "Saved"} | |
}, | |
"efg-fa346y-979nj992-ga6331ohh" : { | |
"name" : "Joanna Lit", | |
"type" : "Technical Division", | |
"primarynominator" : "Sam Ryan", | |
"reviewer1" : {"name" : "David La", "grade" : "", "comments" : "", "status" : "Recused"}, | |
"reviewer2" : {"name" : "Bob Hall", "grade" : "A", "comments" : "", "status" : "Saved"}, | |
"adjudicator" : {"name" : "Walter Johnson", "recommendation" : "Yes", "comments" : "", "status" : "Saved"}, | |
"os" : [ | |
{"name" : "Bill Stewert", "vote" : "Yes", "comments" : "", "status" : "Saved"}, | |
{"name" : "Jeffrey Dustin", "vote" : "Yes", "comments" : "", "status" : "Saved"}, | |
{"name" : "Tom Brady", "vote" : "Yes", "comments" : "", "status" : "Saved"} | |
], | |
"oschair" : {"decision" : "Yes", "comments" : "", "status" : "Saved"} | |
} | |
} | |
// loops over the key value pairs and prints | |
// them to the console. for education only | |
// code is not required | |
function printObject(o){ | |
$.each(o, function(key, value){ | |
console.log(key, value); | |
}); | |
} | |
// takes users full name, returns matching user id | |
function getIdFromName(v){ | |
var id; | |
$.each(obj, function(key, value){ | |
if (v === value.name) { | |
id = key; | |
return; | |
} | |
}); | |
return id; | |
}; | |
console.log( getIdFromName("Louise Voress") ); | |
console.log( getIdFromName("Joanna Lit") ); | |
printObject(users) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment