-1

我正在尝试访问以下对象中的“1h”键:

  {
    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'
    }
  }, 

但因为它是 json 而对象中的其他键不是,所以我无法使用 JSON.parse 解析完整的对象。请问如何使用点符号访问“1h”键及其子键?

4

1 回答 1

0

使用此代码:

const h1 = jsonResponce['1h'];
于 2020-12-16T11:21:06.773 回答