JSON数据&JavaScript(试图找到错误,可能只是语法)

JSON data & JavaScript (trying to find error, maybe just syntax)

本文关键字:语法 错误 JavaScript 数据 JSON      更新时间:2023-09-26

似乎我有一个语法问题…但我不能确定这一点。我已经通过了一个验证器,但似乎不能解决它。

var data ={
  "created":"2014-10-17T14:42:39Z
    ",
  "lang":"en-US",
  "location":{"city": "Orlando", "country": "United States", "region": "FL
    "},
  "results":{
    "units":{"
    distance": "mi", "pressure": "ins", "speed": "mph", "temperature": "F
    "},
    "wind":{"chill": "76", "direction": "360", "speed": "5
    "},
    "atmosphere":{"humidity": "48", "pressure": "29.65", "rising": "0", "visibility": "10
    "},
    "astronomy":{"sunrise": "7:26 am", "sunset": "6:51 pm
    "},
    "condition":{"code": "33", "date": "Fri, 17 Oct 2014 5:53 am EST", "temp": "76", "text": "Fair
    "},
    "forecast":[
      {
        "code":"30",
        "date":"17",
        "Oct":"2014",
        "day":"Fri",
        "high":"80",
        "low":"62",
        "text":"Sunny"
        },{
          "code":"30",
          "date":"18",
          "Oct":"2014",
          "day":"Sat",
          "high":"82",
          "low":"63",
          "text":"Partly Cloudy"
          },{
            "code":"30",
            "date":"19",
            "Oct":"2014",
            "day":"Sun",
            "high":"85",
            "low":"65",
            "text":"Partly Cloudy

    "
          }
        ]
      }
      };
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="data.json"></script>
</head>
<body>
  <h1>JSON in Console</h1>
  <script>
  console.log(data.data.results.forecast[2].day);
  </script>
</body>
</html>

我试图让HTML内的脚本标签运行,并在控制台窗口交付结果。

第一行的" created "后面有一个隐藏的非法字符