我有一个JavaScript对象,如下所示。
{
"28903218": {
"type": "group",
"prompt": "Cool, thanks! Now tell us about your child's day:",
"description": ""
},
"37742463": {
"type": "choice",
"prompt": "How does {{answer_28903220}} react in an unwelcome situation?",
"description": "(Such as not wanting to be in the car seat, when you're not in the room at bedtime, etc.)"
},
"30035493": {
"type": "choice",
"prompt": "Friday:",
"description": ""
},
}
我有一个问题需要阅读。如何获得28903218
属性的值?
surveyData.getQuestions().subscribe(
result => {
//here I need to get the "28903218" object's value
},
err => { },
() => { }
);
答案 0 :(得分:0)
假设您知道28903218
:
var value = result["28903218"];
如果您不了解它,那么您可以遍历这些属性,直到找到所需的属性:
for (var prop in result) {
var value = result[prop];
}