0

How do I access object attributes whose name contains a number and dot and spaces?

my REST API response is:

{
  "Global Quote": {
    "01. symbol": "WDI.FRK",
    "02. open": "147.5000",
    "03. high": "150.1000",
    "04. low": "130.3000",
    "05. price": "139.7500",
    "06. volume": "79625",
    "07. latest trading day": "2019-05-31",
    "08. previous close": "154.0000",
    "09. change": "-14.2500",
    "10. change percent": "-9.2532%"
  }
}

This notation does not work:

  var data                  = response;
  var price= data.Global%x20Quote.05.%x20price;
melpomene
  • 84,125
  • 8
  • 85
  • 148

2 Answers2

4

This should work: const price = data['Global Quote']['05. price']

emcee22
  • 1,851
  • 6
  • 23
  • 32
0

User square brackets, like this

 var data = data['Global Quote']['05. price']