Let's say I have this in JavaScript object taken from a Firebase query.
{
"player": {
"player:616320": {
"skills": {
"main": {
"attack": 1,
"defence": 1
}
},
"uid": "player:616320",
"username": "test1",
"x": 1,
"y": 1
}
}
}
var data = snap.val();
I can do data.username to get test1... but how would I go further? I tried searching JSON nesting and ... it was complicated.
And snap.val() is the JSON object above. How ould I get the attack from main?
datais the whole object thendata.usernamewon't work - you'd needdata.player["player:616320"].usernamedata.usernamegives youtest1, thendatais probablyplayer:616320in the tree. To get the value ofattackI would think you can usedata.skills.main.attack.data.usernameworks then the rest is of the same format. As indata.skills.main.attackto get the value1. Basically just add.and whatever keys you want or you want to go into.