我有以下从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