We help IT Professionals succeed at work.
Get Started

trouble with JSON - can I dump the results that come back/

Tom Knowlton
Tom Knowlton asked
on
542 Views
Last Modified: 2012-05-12
Some of the content returned by my jsonp call does not seem to be present, even though I believe my lookup syntax is correct.  For example, I can get the temperature okay, but not the weather conditions.  So I want to see if what I am getting back actually has "weather" as empty, or if I am doing something wrong ,or can use some other option.

Is there a way to dump the entire contents of "parsed_json" that are coming back?

Here is the call:

jQuery(document).ready(function($) {
	$.ajax({
		url: "http://api.wunderground.com/api/003714f6d717816a/geolookup/conditions/forecast/q/UT/American_Fork.json",
		dataType: "jsonp",
		success: function(parsed_json) {
			var weather = parsed_json['current_observation']['weather'];
			var temp_f = parsed_json['current_observation']['temp_f'];

//alert(weather);  //comes back empty

alert(temp_f);  //works correctly, shows the temperature

		}
	});
});
</script>

Open in new window




Here is a sample of the returned values inside of "parsed_json":

{
	"response": {
		"version": "0.1",
		"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
		"features": {
			"geolookup": 1,
			"conditions": 1,
			"forecast": 1
		}
	}
	,
	"location": {
		"type": "CITY",
		"country": "US",
		"country_iso3166": "US",
		"country_name": "USA",
		"state": "CA",
		"city": "San Francisco",
		"tz_short": "PDT",
		"tz_long": "America/Los_Angeles",
		"lat": "37.77500916",
		"lon": "-122.41825867",
		"zip": "94101",
		"magic": "1",
		"wmo": "99999",
		"l": "/q/zmw:94101.1.99999",
		"requesturl": "US/CA/San_Francisco.html",
		"wuiurl": "http://www.wunderground.com/US/CA/San_Francisco.html",
		"nearby_weather_stations": {
			"airport": {
				"station": [
					{
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"icao": "KSFO",
						"lat": "37.61999893",
						"lon": "-122.37000275"
					},
					{
						"city": "Oakland",
						"state": "CA",
						"country": "US",
						"icao": "KOAK",
						"lat": "37.72000122",
						"lon": "-122.22000122"
					},
					{
						"city": "Hayward",
						"state": "CA",
						"country": "US",
						"icao": "KHWD",
						"lat": "37.65999985",
						"lon": "-122.12000275"
					},
					{
						"city": "Half Moon Bay",
						"state": "CA",
						"country": "US",
						"icao": "KHAF",
						"lat": "37.50999832",
						"lon": "-122.50000000"
					}
				]
			},
			"pws": {
				"station": [
					{
						"neighborhood": "SOMA - Near Van Ness",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR58",
						"distance_km": 0,
						"distance_mi": 0
					},
					{
						"neighborhood": "North Mission (Valencia & Market)",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR49",
						"distance_km": 0,
						"distance_mi": 0
					},
					{
						"neighborhood": "HADS SAN FRANCISCO DOWNTOWN CA US",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "MSFOC1",
						"distance_km": 1,
						"distance_mi": 0
					},
					{
						"neighborhood": "SoMa",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR113",
						"distance_km": 1,
						"distance_mi": 1
					},
					{
						"neighborhood": "Mission Bay - My weather is better than yours.",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR53",
						"distance_km": 1,
						"distance_mi": 1
					},
					{
						"neighborhood": "Castro/San Francisco",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KPCASANF2",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "The Castro",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR114",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "China Basin Landing",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR14",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "The Mission: Even the weather is hip",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR79",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "Potrero Hill",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR108",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "Financial District",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR102",
						"distance_km": 2,
						"distance_mi": 1
					},
					{
						"neighborhood": "Cole Valley",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR110",
						"distance_km": 3,
						"distance_mi": 1
					},
					{
						"neighborhood": "Billy Goat Hill",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR73",
						"distance_km": 3,
						"distance_mi": 2
					},
					{
						"neighborhood": "Marina District",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR82",
						"distance_km": 4,
						"distance_mi": 2
					},
					{
						"neighborhood": "Twin Peaks",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR34",
						"distance_km": 4,
						"distance_mi": 2
					},
					{
						"neighborhood": "APRSWXNET San Francisco CA US",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "MC9629",
						"distance_km": 4,
						"distance_mi": 2
					},
					{
						"neighborhood": "MesoWest San Fran Sewage Treatment Plant CA US CARB",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "MCQ147",
						"distance_km": 4,
						"distance_mi": 2
					},
					{
						"neighborhood": "Mid Richmond",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR128",
						"distance_km": 4,
						"distance_mi": 2
					},
					{
						"neighborhood": "Forest Hill",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR72",
						"distance_km": 5,
						"distance_mi": 3
					},
					{
						"neighborhood": "Sunnyside",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR70",
						"distance_km": 5,
						"distance_mi": 3
					},
					{
						"neighborhood": "Forest Hill",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR109",
						"distance_km": 5,
						"distance_mi": 3
					},
					{
						"neighborhood": "Sherwood Forest",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR129",
						"distance_km": 5,
						"distance_mi": 3
					},
					{
						"neighborhood": "Mid Richmond District",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR97",
						"distance_km": 5,
						"distance_mi": 3
					},
					{
						"neighborhood": "Ocean Beach - Kellys Cove",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR99",
						"distance_km": 8,
						"distance_mi": 4
					},
					{
						"neighborhood": "APRSWXNET San Francisco CA US",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "MAS891",
						"distance_km": 8,
						"distance_mi": 4
					},
					{
						"neighborhood": "Ingleside District",
						"city": "San Francisco",
						"state": "CA",
						"country": "US",
						"id": "KCASANFR100",
						"distance_km": 8,
						"distance_mi": 5
					}
				]
			}
		}
	}
	,
	"current_observation": {
		"image": {
			"url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
			"title": "Weather Underground",
			"link": "http://wunderground.com"
		},
		"display_location": {
			"full": "San Francisco, CA",
			"city": "San Francisco",
			"state": "CA",
			"state_name": "California",
			"country": "US",
			"country_iso3166": "US",
			"zip": "94101",
			"latitude": "37.77500916",
			"longitude": "-122.41825867",
			"elevation": "47.00000000"
		},
		"observation_location": {
			"full": "SOMA - Near Van Ness, San Francisco, California",
			"city": "SOMA - Near Van Ness, San Francisco",
			"state": "California",
			"country": "US",
			"country_iso3166": "US",
			"latitude": "37.773285",
			"longitude": "-122.417725",
			"elevation": "49 ft"
		},
		"station_id": "KCASANFR58",
		"observation_time": "Last Updated on September 21, 10:47 AM PDT",
		"observation_time_rfc822": "Wed, 21 Sep 2011 10:47:07 -0700",
		"observation_epoch": "1316627227",
		"local_time_rfc822": "Wed, 21 Sep 2011 10:47:19 -0700",
		"local_epoch": "1316627239",
		"weather": "Clear",
		"temperature_string": "69.7 F (20.9 C)",
		"temp_f": 69.7,
		"temp_c": 20.9,
		"relative_humidity": "69%",
		"wind_string": "Calm",
		"wind_dir": "NNW",
		"wind_degrees": 335,
		"wind_mph": 0.0,
		"wind_gust_mph": "1.0",
		"pressure_mb": "1012.8",
		"pressure_in": "29.91",
		"pressure_trend": "0",
		"dewpoint_string": "59 F (15 C)",
		"dewpoint_f": 59,
		"dewpoint_c": 15,
		"heat_index_string": "NA",
		"heat_index_f": "NA",
		"heat_index_c": "NA",
		"windchill_string": "NA",
		"windchill_f": "NA",
		"windchill_c": "NA",
		"visibility_mi": "10.0",
		"visibility_km": "16.1",
		"icon": "clear",
		"icon_url": "http://icons-ak.wxug.com/i/c/k/clear.gif",
		"forecast_url": "http://www.wunderground.com/US/CA/San_Francisco.html",
		"history_url": "http://www.wunderground.com/history/airport/KCASANFR58/2011/9/21/DailyHistory.html",
		"ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.773285,-122.417725"
	}
	,
	"forecast": {
		"txt_forecast": {
			"date": "1:40 AM PDT",
			"forecastday": [
				{
					"period": 1,
					"icon": "partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
					"title": "Today",
					"fcttext": "Partly cloudy. Highs in the mid 60s to lower 80s. Light winds...becoming west 5 to 10 mph in the afternoon. "
				},
				{
					"period": 2,
					"icon": "nt_sunny",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/nt_sunny.gif",
					"title": "Tonight",
					"fcttext": "Clear in the evening then becoming partly cloudy. Lows in the mid 50s. West winds 5 to 10 mph. "
				},
				{
					"period": 3,
					"icon": "cloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/cloudy.gif",
					"title": "Thursday",
					"fcttext": "Mostly cloudy in the morning then becoming partly cloudy. Patchy fog in the morning. Highs in the 60s to lower 70s. Light winds...becoming west 5 to 10 mph in the afternoon. "
				},
				{
					"period": 4,
					"icon": "nt_partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/nt_partlycloudy.gif",
					"title": "Thursday Night",
					"fcttext": "Partly cloudy in the evening then becoming cloudy. Patchy fog after midnight. Lows in the mid 50s. West winds 5 to 10 mph. "
				},
				{
					"period": 5,
					"icon": "cloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/cloudy.gif",
					"title": "Friday",
					"fcttext": "Cloudy in the morning then becoming sunny. Patchy fog in the morning. Highs in the 60s to lower 70s. Light winds... becoming west around 5 mph in the afternoon. "
				}
			]
		},
		"simpleforecast": {
			"forecastday": [
				{
					"date": {
						"epoch": "1316671249",
						"pretty": "11:00 PM PDT on September 21, 2011",
						"day": 21,
						"month": 9,
						"year": 2011,
						"yday": 263,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Wed",
						"weekday": "Wednesday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 1,
					"high": {
						"fahrenheit": "81",
						"celsius": "27"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Partly Cloudy",
					"icon": "partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
					"skyicon": "mostlysunny",
					"pop": 0
				},
				{
					"date": {
						"epoch": "1316757649",
						"pretty": "11:00 PM PDT on September 22, 2011",
						"day": 22,
						"month": 9,
						"year": 2011,
						"yday": 264,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Thu",
						"weekday": "Thursday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 2,
					"high": {
						"fahrenheit": "72",
						"celsius": "22"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Clear",
					"icon": "clear",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/clear.gif",
					"skyicon": "mostlysunny",
					"pop": 0
				},
				{
					"date": {
						"epoch": "1316844049",
						"pretty": "11:00 PM PDT on September 23, 2011",
						"day": 23,
						"month": 9,
						"year": 2011,
						"yday": 265,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Fri",
						"weekday": "Friday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 3,
					"high": {
						"fahrenheit": "72",
						"celsius": "22"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Clear",
					"icon": "clear",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/clear.gif",
					"skyicon": "mostlysunny",
					"pop": 0
				},
				{
					"date": {
						"epoch": "1316930449",
						"pretty": "11:00 PM PDT on September 24, 2011",
						"day": 24,
						"month": 9,
						"year": 2011,
						"yday": 266,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Sat",
						"weekday": "Saturday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 4,
					"high": {
						"fahrenheit": "65",
						"celsius": "18"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Partly Cloudy",
					"icon": "partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
					"skyicon": "mostlysunny",
					"pop": 0
				},
				{
					"date": {
						"epoch": "1317016849",
						"pretty": "11:00 PM PDT on September 25, 2011",
						"day": 25,
						"month": 9,
						"year": 2011,
						"yday": 267,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Sun",
						"weekday": "Sunday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 5,
					"high": {
						"fahrenheit": "63",
						"celsius": "17"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Partly Cloudy",
					"icon": "partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
					"skyicon": "partlycloudy",
					"pop": 10
				},
				{
					"date": {
						"epoch": "1317103249",
						"pretty": "11:00 PM PDT on September 26, 2011",
						"day": 26,
						"month": 9,
						"year": 2011,
						"yday": 268,
						"hour": 23,
						"min": "00",
						"sec": 49,
						"isdst": "1",
						"monthname": "September",
						"weekday_short": "Mon",
						"weekday": "Monday",
						"ampm": "PM",
						"tz_short": "PDT",
						"tz_long": "America/Los_Angeles"
					},
					"period": 6,
					"high": {
						"fahrenheit": "67",
						"celsius": "19"
					},
					"low": {
						"fahrenheit": "54",
						"celsius": "12"
					},
					"conditions": "Partly Cloudy",
					"icon": "partlycloudy",
					"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
					"skyicon": "partlycloudy",
					"pop": 10
				}
			]
		}
	}
}

Open in new window




Here is the site URL I am working with:

http://api.wunderground.com/weather/api/d/documentation.html
Comment
Watch Question
Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE