Reputation: 21617
I cannot figure this out at all.
my current json results the following using console.log(json)
I was wondering if someone could help me retrieve the Condition part?
EDIT
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);
});
Upvotes: 1
Views: 2048
Reputation: 3794
Item is already parsed so save what that pages sends back to varible test and code below iwll work
and access things like..
test.query.results.item.condition.text
Which will return a value
To do conditions you could do
var b = test.query.results.item.condition.text ;
if(b == ???)
or even > or < or what ever is required
Upvotes: 0
Reputation: 57650
Use native JSON object.
var obj = JSON.parse(json);
var condition = obj.query.results.channel.item.condition;
Upvotes: 1
Reputation: 19539
You need to use parseJSON
: http://api.jquery.com/jQuery.parseJSON/
Then just access the Condition
var like you would any object property.
Upvotes: 1