I did a lot of research on this site, so forgive me if I did not find the right answer before posting this. I'm specifically trying to extract data from the weather channel wundergound API to display 7-10 day weather forecasts on our ColdFusion website. I have no problem with outputting results from JSON that are not in the JSON array.
Here is the specific WORK code that I use to display the results of one-day weather:
<cfhttp url="http://api.wunderground.com/api/02e63b13f45e6430/forecast/geolookup/conditions/q/CA/San_Francisco.json">
<cfset parsed_json = deserializeJSON(cfhttp.fileContent)>
<cfset location = parsed_json.location.city>
<cfset weather = parsed_json.current_observation.weather>
<cfset temp_f = parsed_json.current_observation.temp_f>
<cfoutput>
<div class="weather-info">
<span class="current-conditions">Current Conditions</span>
<span class="weather-location">#location#</span>
<center>#weather#</center>
<span class="weather-temp-f">#temp_f# <sup>°</sup></span>
</cfoutput>
, , 7-10 JSON ColdFusion. . ColdFusion . , . / JSON:
http://api.wunderground.com/api/02e63b13f45e6430/forecast/geolookup/conditions/q/CA/San_Francisco.json
: http://suiteamerica.com/images/JSON_array.jpg
JSON,
"forecast":{
"txt_forecast": {
"date":"10:01 AM PDT",
"forecastday": [
{
"period":0,
"icon":"cloudy",
"icon_url":"http://icons.wxug.com/i/c/k/cloudy.gif",
"title":"Tuesday",
"fcttext":"Cloudy. Slight chance of a rain shower. High 64F. Winds W at 10 to 15 mph.",
"fcttext_metric":"Cloudy skies. Slight chance of a rain shower. High 18C. Winds W at 15 to 25 km/h.",
"pop":"20"
}
,
{
"period":1,
"icon":"nt_cloudy",
"icon_url":"http://icons.wxug.com/i/c/k/nt_cloudy.gif",
"title":"Tuesday Night",
"fcttext":"Cloudy. Slight chance of a rain shower. Low 52F. Winds SW at 10 to 15 mph.",
"fcttext_metric":"Cloudy. Slight chance of a rain shower. Low 11C. Winds WSW at 15 to 25 km/h.",
"pop":"20"
}
,
{
"period":2,
"icon":"mostlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/mostlycloudy.gif",
"title":"Wednesday",
"fcttext":"Mostly cloudy skies. High 63F. Winds SW at 10 to 20 mph.",
"fcttext_metric":"Mostly cloudy. High 17C. Winds SW at 15 to 30 km/h.",
"pop":"20"
}
,
{
"period":3,
"icon":"nt_mostlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/nt_mostlycloudy.gif",
"title":"Wednesday Night",
"fcttext":"Partly cloudy during the evening followed by cloudy skies overnight. Slight chance of a rain shower. Low 53F. Winds SW at 10 to 20 mph.",
"fcttext_metric":"Partly cloudy skies during the evening will give way to cloudy skies overnight. Slight chance of a rain shower. Low 11C. Winds SW at 15 to 30 km/h.",
"pop":"20"
}
,
{
"period":4,
"icon":"partlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
"title":"Thursday",
"fcttext":"Cloudy skies early, followed by partial clearing. High 64F. Winds WSW at 10 to 20 mph.",
"fcttext_metric":"Cloudy early with partial sunshine expected late. High 17C. Winds WSW at 15 to 30 km/h.",
"pop":"20"
}
,
{
"period":5,
"icon":"nt_chancerain",
"icon_url":"http://icons.wxug.com/i/c/k/nt_chancerain.gif",
"title":"Thursday Night",
"fcttext":"Partly cloudy skies early followed by mostly cloudy skies and a few showers later at night. Low 52F. Winds WSW at 10 to 15 mph. Chance of rain 30%.",
"fcttext_metric":"Partly cloudy during the evening. A few showers developing later during the night. Low 11C. Winds WSW at 15 to 30 km/h. Chance of rain 30%.",
"pop":"30"
}
,
{
"period":6,
"icon":"chancerain",
"icon_url":"http://icons.wxug.com/i/c/k/chancerain.gif",
"title":"Friday",
"fcttext":"Rain showers in the morning becoming more intermittent in the afternoon. High 63F. Winds SW at 10 to 15 mph. Chance of rain 50%.",
"fcttext_metric":"Showers early becoming less numerous later in the day. High 17C. Winds SW at 15 to 25 km/h. Chance of rain 50%.",
"pop":"50"
}
,
{
"period":7,
"icon":"nt_mostlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/nt_mostlycloudy.gif",
"title":"Friday Night",
"fcttext":"Partly cloudy skies during the evening will give way to cloudy skies overnight. Low 54F. Winds SSW at 5 to 10 mph.",
"fcttext_metric":"Partly cloudy during the evening followed by cloudy skies overnight. Low 12C. Winds SSW at 10 to 15 km/h.",
"pop":"20"
}
]
},
, wunderground, , - , .
DATE , :
<cfset fctdate = parsed_json.forecast.txt_forecast.date>
, 7-10 JSON.
JSON CFSET, , [0] ..?? CFLOOP, ? , CFLOOP, 7-10 ?
. , , . , - . , .