Чтобы получить значения из объекта, вы можете l oop по клавишам:
const data = {
'Meta Data': {
'1. Information': 'info',
'2. Symbol': 'symbol',
'3. Last Refreshed': '2020-05-40',
'4. Output Size': 'output',
'5. Time Zone': 'time zone'
},
'Time Series (Daily)': {
someKey: {
'1. open': 'someKey#open',
'2. high': 'someKey#high',
'3. low': 'someKey#open',
'4. close': 'someKey#close',
'5. volume': 'someKey#volume',
},
someOtherKey: {
'1. open': 'someOtherKey#open',
'2. high': 'someOtherKey#high',
'3. low': 'someOtherKey#open',
'4. close': 'someOtherKey#close',
'5. volume': 'someOtherKey#volume',
}
}
};
const timeSeries = data['Time Series (Daily)'];
const parentKeys = Object.keys(timeSeries);
parentKeys.forEach(parentKey => {
const parentValue = timeSeries[parentKey];
const childKeys = Object.keys(parentValue);
console.group(`Values for ${parentKey}:`);
childKeys.forEach(childKey => {
console.log({ key: childKey, value: parentValue[childKey] });
});
console.groupEnd();
});
Обратите внимание, что для этого образца я следую форме предоставленных интерфейсов .