我有以下從API輸出的JSON數組。使用javascript將JSON數組轉換爲單個變量
{
"location": {
"name": "Alanallur",
"region": "Kerala",
"country": "India",
"lat": 11.01,
"lon": 76.33,
"tz_id": "Asia/Kolkata",
"localtime_epoch": 1470998311,
"localtime": "2016-08-12 10:38"
},
"current": {
"last_updated_epoch": 1470997826,
"last_updated": "2016-08-12 10:30",
"temp_c": 28.0,
"temp_f": 82.4,
"is_day": 1,
"condition": {
"text": "Moderate rain",
"icon": "//cdn.apixu.com/weather/64x64/day/302.png",
"code": 1189
},
"wind_mph": 8.1,
"wind_kph": 13.0,
"wind_degree": 340,
"wind_dir": "NNW",
"pressure_mb": 1013.0,
"pressure_in": 30.4,
"precip_mm": 0.0,
"precip_in": 0.0,
"humidity": 79,
"cloud": 0,
"feelslike_c": 32.2,
"feelslike_f": 89.9
}
}
我想使用JavaScript
1)你沒有陣列存在,2)JSON沒有陣列,它是一個字符串,3)解析時,你將有一個JavaScript OB ject,沒有數組 –
您在JSON字符串中沒有數組。 http://json-parser.com/6d51ab22你想要哪個字段作爲單獨的變量? –
'location'和'current'是兩個結果變量嗎? – guest271314