访问json接口数据得到:
{
{
"HeWeather data service 3.0":[
{"city":"beijing",...},
{"weather":"sunny",....}
]
}
}
使用js访问,代码如下:
$.ajax(url,{
//...
success:function(data){
console.log(data);//返回的是对象
console.log(data[0]);//返回undefine
}
//...
要想得到json中的"city"值,该怎样写
你问题中的JSON格式有问题,如果是下面的格式
要想得到JSON中的"city"值