从API循环JSON对象-无法循环或映射对象

时间:2019-10-05 17:44:45

标签: javascript json loops

{
  "Meta Data": {
    "1. Information": "Weekly Adjusted Prices and Volumes",
    "2. Symbol": "SAP",
    "3. Last Refreshed": "2019-10-04",
    "4. Time Zone": "US/Eastern"
  },
  "Weekly Adjusted Time Series": {
    "2019-10-04": {
      "1. open": "117.2600",
      "2. high": "118.3400",
      "3. low": "112.8900",
      "4. close": "115.3700",
      "5. adjusted close": "115.3700",
      "6. volume": "4080017",
      "7. dividend amount": "0.0000"
    },
    "2019-09-27": {
      "1. open": "118.8600",
      "2. high": "119.9400",
      "3. low": "116.2500",
      "4. close": "117.4400",
      "5. adjusted close": "117.4400",
      "6. volume": "5829900",
      "7. dividend amount": "0.0000"
    }
  }
}

我知道我需要一个数组来循环,但是下面的代码为什么不起作用?

let data = temp1["Weekly Adjusted Time Series"]
let result = data.map(function(open) {
  return open["1. open"];
});

data.map is not a function
    at <anonymous>:1:6

猜猜这是一个愚蠢的问题,但是请您能帮我吗?我完全不了解JSON和JS,因此在这里找不到解决我问题的解决方案。

0 个答案:

没有答案