1

I cannot figure this out at all.

my current json results the following using console.log(json)

Click to view Json Response

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);
                     });
ngplayground
  • 20,365
  • 36
  • 94
  • 173

3 Answers3

1

You need to use parseJSON: http://api.jquery.com/jQuery.parseJSON/

Then just access the Condition var like you would any object property.

Madbreaks
  • 19,094
  • 7
  • 58
  • 72
1

Use native JSON object.

var obj = JSON.parse(json);
var condition = obj.query.results.channel.item.condition;
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
0

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

Lemex
  • 3,772
  • 14
  • 53
  • 87