Answer the question
In order to leave comments, you need to log in
How to get all the necessary properties from an object?
It is necessary to get names of users from object. It's not really possible to do this. There are three vows in the dills object. You need to go through all 3. then go to Participants. And there are also three objects that contain the names of people. How to get these names into a separate array?
It needs to be like this [denis, nikolay, vladeslav] and so all the names.
This is the object I have:
var json_date = [{
"dills": {
"1": {
"Participants": {
"1": {
"denis": {
"url": "img/humen.png"
}
},
"2": {
"nikolya": {
"url": "img/humen.png"
}
},
"3": {
"anton ": {
"url": "img/humen.png"
}
}
}
},
"2": {
"Participants": {
"1": {
"Vladeslav": {
"url": "img/humen.png"
}
},
"2": {
"Nikita": {
"url": "img/humen.png"
}
},
"3": {
"Andrey": {
"url": "img/humen.png"
}
}
}
},
"3": {
"Participants": {
"1": {
"Olga": {
"url": "img/humen.png"
}
},
"2": {
"Lina": {
"url": "img/humen.png"
}
}
}
}
}
}]
Answer the question
In order to leave comments, you need to log in
In haste
var users = [];
for(key in json_date[0].dills) {
for(name in json_date[0].dills[key].Participants) {
users.push(Object.keys(json_date[0].dills[key].Participants[name]).toString())
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question