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
  • 18,559
  • 34
  • 93
  • 168

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
  • 18,119
  • 7
  • 53
  • 69
1

Use native JSON object.

var obj = JSON.parse(json);
var condition = obj.query.results.channel.item.condition;
Shiplu Mokaddim
  • 54,465
  • 14
  • 131
  • 183
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,734
  • 14
  • 50
  • 87