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

时间:2016-09-16 19:09:56

标签: javascript json

好像我有一个语法问题......但我不能指出这个问题。我已经通过了验证器,但似乎无法解决这个问题。



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>
&#13;
&#13;
&#13;

我正在尝试在HTML中获取脚本标记以运行并在控制台窗口中传递结果。

1 个答案:

答案 0 :(得分:0)

在第一行“创建”一词后面有一个隐藏的非法字符