I would like to get the value of “name” from the example json object below without knowing the name of the object (123) because this could be anything and I dont know before.
It’s not an ionic question. You can use StackOverflow for same questions.
Even so,
var data = {
"123": {
"email": "kato@firebase.com",
"name": "Kato"
}
}
var name;
for (var key in data) {
if (data[key].hasOwnProperty("name")) {
name = data[key].name;
break;
}
}
Thanks, I know this was not ionic issue but I guess there is a bunch of people around here which use ionic/firebase and might have the same situation sooner or later. thx anyway. solved it for me.