openweather雨json没有显示

时间:2016-09-21 08:15:31

标签: jquery html json openweathermap

<body>

<p id="demo"></p>

<script>
var txt = '{"coord":{"lon":108.27,"lat":-7.68},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"stations","main":{"temp":26.97,"pressure":1010.86,"humidity":100,"temp_min":26.97,"temp_max":26.97,"sea_level":1021.57,"grnd_level":1010.86},"wind":{"speed":1.61,"deg":232.009},"rain":{"3h":1.88},"clouds":{"all":56},"dt":1474443506,"sys":{"message":0.1676,"country":"ID","sunrise":1474411011,"sunset":1474454577},"id":8044852,"name":"Bojongsari","cod":200}';

var obj = eval ("(" + txt + ")");

document.getElementById("demo").innerHTML =
obj.rain.3h 
</script>

</body>

为什么 obj.rain.3h 没有显示,而另一个成功如obj.clouds.all

0 个答案:

没有答案