Weather app HAX & parsing objects?

I have a hack kinda thing for the weather app, which skips
using app keys and navigator geo loc etc, but i cant figure out how to parse the
bloody thing?

thnx for any help :stuck_out_tongue:
https://codepen.io/Xiija/pen/MVqpga?editors=0011
or
https://codepen.io/Xiija/pen/xWaXrM?editors=0011
( check the console log? )

You probably should review how to reference nested objects with the following challenge.
https://www.freecodecamp.org/challenges/accessing-nested-objects

The bulk of the information is located in data.query.results.channel

        $.getJSON(getWeather , function(data) {       
          console.log(JSON.stringify(data.query.results.channel));
        }); 

I get the following object displayed to the console running the above code.

{
  "units": {
    "distance": "mi",
    "pressure": "in",
    "speed": "mph",
    "temperature": "F"
  },
  "title": "Yahoo! Weather - San Jose, CA, US",
  "link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-55971183/",
  "description": "Yahoo! Weather for San Jose, CA, US",
  "language": "en-us",
  "lastBuildDate": "Wed, 04 Apr 2018 04:37 PM PDT",
  "ttl": "60",
  "location": {
    "city": "San Jose",
    "country": "United States",
    "region": " CA"
  },
  "wind": {
    "chill": "66",
    "direction": "345",
    "speed": "14"
  },
  "atmosphere": {
    "humidity": "51",
    "pressure": "1004.0",
    "rising": "0",
    "visibility": "16.1"
  },
  "astronomy": {
    "sunrise": "6:49 am",
    "sunset": "7:33 pm"
  },
  "image": {
    "title": "Yahoo! Weather",
    "width": "142",
    "height": "18",
    "link": "http://weather.yahoo.com",
    "url": "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
  },
  "item": {
    "title": "Conditions for San Jose, CA, US at 04:00 PM PDT",
    "lat": "37.341999",
    "long": "-121.884727",
    "link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-55971183/",
    "pubDate": "Wed, 04 Apr 2018 04:00 PM PDT",
    "condition": {
      "code": "26",
      "date": "Wed, 04 Apr 2018 04:00 PM PDT",
      "temp": "66",
      "text": "Cloudy"
    },
    "forecast": [
      {
        "code": "26",
        "date": "04 Apr 2018",
        "day": "Wed",
        "high": "70",
        "low": "50",
        "text": "Cloudy"
      },
      {
        "code": "26",
        "date": "05 Apr 2018",
        "day": "Thu",
        "high": "67",
        "low": "48",
        "text": "Cloudy"
      },
      {
        "code": "11",
        "date": "06 Apr 2018",
        "day": "Fri",
        "high": "64",
        "low": "54",
        "text": "Showers"
      },
      {
        "code": "11",
        "date": "07 Apr 2018",
        "day": "Sat",
        "high": "65",
        "low": "55",
        "text": "Showers"
      },
      {
        "code": "30",
        "date": "08 Apr 2018",
        "day": "Sun",
        "high": "66",
        "low": "50",
        "text": "Partly Cloudy"
      },
      {
        "code": "28",
        "date": "09 Apr 2018",
        "day": "Mon",
        "high": "71",
        "low": "46",
        "text": "Mostly Cloudy"
      },
      {
        "code": "39",
        "date": "10 Apr 2018",
        "day": "Tue",
        "high": "67",
        "low": "50",
        "text": "Scattered Showers"
      },
      {
        "code": "39",
        "date": "11 Apr 2018",
        "day": "Wed",
        "high": "68",
        "low": "50",
        "text": "Scattered Showers"
      },
      {
        "code": "39",
        "date": "12 Apr 2018",
        "day": "Thu",
        "high": "64",
        "low": "50",
        "text": "Scattered Showers"
      },
      {
        "code": "34",
        "date": "13 Apr 2018",
        "day": "Fri",
        "high": "69",
        "low": "47",
        "text": "Mostly Sunny"
      }
    ],
    "description": "<![CDATA[<img src=\"http://l.yimg.com/a/i/us/we/52/26.gif\"/>\n<BR />\n<b>Current Conditions:</b>\n<BR />Cloudy\n<BR />\n<BR />\n<b>Forecast:</b>\n<BR /> Wed - Cloudy. High: 70Low: 50\n<BR /> Thu - Cloudy. High: 67Low: 48\n<BR /> Fri - Showers. High: 64Low: 54\n<BR /> Sat - Showers. High: 65Low: 55\n<BR /> Sun - Partly Cloudy. High: 66Low: 50\n<BR />\n<BR />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-55971183/\">Full Forecast at Yahoo! Weather</a>\n<BR />\n<BR />\n<BR />\n]]>",
    "guid": {
      "isPermaLink": "false"
    }
  }
}
1 Like

TYSM!
i had to use an online parser to figure out the nesting…
http://json.parser.online.fr/