-1

I have a JavaScript object as shown below.

{
    "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": ""
    }, 
}

I have a problem to read it. How can I get the 28903218 property's value?

 surveyData.getQuestions().subscribe(
      result => {
        //here I need to get the "28903218" object's value 
      },
      err => { },
      () => { }
    );
Sampath
  • 63,341
  • 64
  • 307
  • 441
  • Possible duplicate of [How to access a numeric property?](http://stackoverflow.com/questions/2026741/how-to-access-a-numeric-property) –  Apr 29 '17 at 06:14

1 Answers1

0

Assuming that you know 28903218:

var value = result["28903218"];

If you don't know it then you could loop through the properties until you find the desired one:

for (var prop in result) {
    var value = result[prop];
}
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    @torazaburo, no idea, if you don't know what you are looking for, then how do you expect to find it? If you have no clues or patterns to identify it - then you are probably wasting your time :-) Normally when you are looking for something you know how it looks or at least how to identify it. – Darin Dimitrov Apr 29 '17 at 18:58