在jquery Yahoo Weather API中解析JSON



我根本想不出来。

我当前的json使用console.log(json) 得到以下结果

点击查看Json响应

我想知道是否有人可以帮我取回条件部分?

编辑

                       var geoFORECAST = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid=%2726344339%27%20and%20u=%27c%27&format=json';
                    $.getJSON(geoFORECAST, function(json) {
                       console.log(json);
                       console.log(json.query.results.item.condition.text);
                     });

使用本机JSON对象。

var obj = JSON.parse(json);
var condition = obj.query.results.channel.item.condition;

您需要使用parseJSON:http://api.jquery.com/jQuery.parseJSON/

然后像访问任何对象属性一样访问Condition变量。

项目已经被解析,所以保存页面发送回可变测试的内容,下面的代码将工作

并访问诸如。。

test.query.results.item.condition.text 

它将返回一个值

要做条件,你可以做

var b =  test.query.results.item.condition.text ;

CCD_ 4或甚至>或<或者需要什么

最新更新