html - Openweathermaps parse json jquery forecast -
i'd display weather forecast. far managed display 1 day.
html & jquery code: http://pastebin.com/cpz0pe7g
the json displayed in format.
{ "cod":"200", "message":0.0152, "city":{ "id":524901, "name":"moscow", "coord":{ "lon":37.615555, "lat":55.75222 }, "country":"ru", "population":1000000 }, "cnt":4, "list":[ { "dt":1375866000, "temp":{ "day":26.19, "min":21.82, "max":26.19, "night":21.82, "eve":25.22, "morn":26.19 }, "pressure":1010.53, "humidity":77, "weather":[ { "id":801, "main":"clouds", "description":"few clouds", "icon":"02d" } ], "speed":1.6, "deg":4, "clouds":24 }, { "dt":1375952400, "temp":{ "day":24.92, "min":17.73, "max":25.32, "night":17.73, "eve":24.71, "morn":17.75 }, "pressure":1013.91, "humidity":71, "weather":[ { "id":800, "main":"clear", "description":"sky clear", "icon":"01d" } ], "speed":1.61, "deg":20, "clouds":0 }, { "dt":1376038800, "temp":{ "day":25.87, "min":16.74, "max":26.65, "night":22.17, "eve":26.42, "morn":16.74 }, "pressure":1011.31, "humidity":71, "weather":[ { "id":800, "main":"clear", "description":"sky clear", "icon":"01d" } ], "speed":1.66, "deg":252, "clouds":0 }, { "dt":1376125200, "temp":{ "day":22.72, "min":19.68, "max":25.42, "night":19.68, "eve":24.82, "morn":21.02 }, "pressure":1007.87, "humidity":73, "weather":[ { "id":502, "main":"rain", "description":"heavy intensity rain", "icon":"10d" } ], "speed":2.11, "deg":278, "clouds":80, "rain":15 } ] }
i can parse first line. how can parse other lines?
when see brackets, it's array, have find variable array key. weather.list[0].temp.day
return 26.19. weather.list[0].weather[0].main
return "clouds" , weather.list[1].weather[0].main
return "clear".
Comments
Post a Comment