-1

I am trying to access the '1h' key in the object below:

  {
    id: 'BTC',
    currency: 'BTC',
    symbol: 'BTC',
    name: 'Bitcoin',
    logo_url: 'https://s3.us-east-2.amazonaws.com/nomics-api/static/images/currencies/btc.svg',
    status: 'active',
    price: '19712.65032374',
    price_date: '2020-12-16T00:00:00Z',
    price_timestamp: '2020-12-16T10:55:00Z',
    circulating_supply: '18572518',
    max_supply: '21000000',
    market_cap: '366113552965',
    num_exchanges: '371',
    num_pairs: '47027',
    num_pairs_unmapped: '5598',
    first_candle: '2011-08-18T00:00:00Z',
    first_trade: '2011-08-18T00:00:00Z',
    first_order_book: '2017-01-06T00:00:00Z',
    rank: '1',
    high: '19712.65032374',
    high_timestamp: '2020-12-16T00:00:00Z',
    '1h': {
      volume: '1859132307.86',
      price_change: '222.74282953',
      price_change_pct: '0.0114',
      volume_change: '913982399.48',
      volume_change_pct: '0.9670',
      market_cap_change: '4137129089.64',
      market_cap_change_pct: '0.0114'
    }
  }, 

but because it is json and the other keys within the object aren't, I cannot parse the full object using JSON.parse. Please how can I access the '1h' key and its child keys using dot notation?

Papi
  • 73
  • 6
  • 1
    Consider using square bracket notation. `object['key']` --- _"I cannot parse the full object using JSON.parse"_ : why not? – evolutionxbox Dec 16 '20 at 11:17
  • The *value* of a property is irrelevant for accessing the property. All that matters is the name of the property. – Felix Kling Dec 16 '20 at 11:31

1 Answers1

0

Use this code:

const h1 = jsonResponce['1h'];
Yuriy Vorobyov
  • 755
  • 4
  • 8