title: How to Pull results OUT of a JSON array and INTO ColdFusion for a 7 day weather forecast
body: <p>I did a bunch of research on this website so forgive me if I didn't find the correct answer prior to posting this. I am specifically trying to pull data from the weather channels wundergound API to display a 7-10 day weather forecast on our ColdFusion website. I have no problem pulling results out of JSON that are NOT within a JSON array.</p>
  
  <p>Here is the specific WORKING code I am using to get single day weather results to display:</p>
  
  <pre><code>&lt;cfhttp url="http://api.wunderground.com/api/02e63b13f45e6430/forecast/geolookup/conditions/q/CA/San_Francisco.json"&gt;
  &lt;cfset parsed_json = deserializeJSON(cfhttp.fileContent)&gt;
  &lt;cfset location = parsed_json.location.city&gt;
  &lt;cfset weather = parsed_json.current_observation.weather&gt;
  &lt;cfset temp_f = parsed_json.current_observation.temp_f&gt;
  
  &lt;cfoutput&gt;
  &lt;div class="weather-info"&gt;
  &lt;span class="current-conditions"&gt;Current Conditions&lt;/span&gt; 
  &lt;span class="weather-location"&gt;#location#&lt;/span&gt;
  &lt;center&gt;#weather#&lt;/center&gt;
  &lt;span class="weather-temp-f"&gt;#temp_f# &lt;sup&gt;&amp;deg;&lt;/sup&gt;&lt;/span&gt;
  &lt;/cfoutput&gt;
  </code></pre>
  
  <p>While the above code is working, I am not clear on how to pull the 7-10 day weather forecast out of the JSON array and bring it into ColdFusion. I have not been able to find an answer after days of research. I re-read my ColdFusion book and did not find the answer their either. The weather channels support and documentation is very poor so they were not very helpful. Here is the JSON file/array:</p>
  
  <p><a href="http://api.wunderground.com/api/02e63b13f45e6430/forecast/geolookup/conditions/q/CA/San_Francisco.json" rel="nofollow">http://api.wunderground.com/api/02e63b13f45e6430/forecast/geolookup/conditions/q/CA/San_Francisco.json</a></p>
  
  <p>Here is a link to a partial screenshot of the array: <a href="http://suiteamerica.com/images/JSON_array.jpg" rel="nofollow">http://suiteamerica.com/images/JSON_array.jpg</a></p>
  
  <p>Here is part of the JSON file's code which has the array <strong>forecastday</strong></p>
  
  <pre><code>"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"
          }
          ]
          },
  </code></pre>
  
  <p>The only thing the weather channels wunderground support did tell me was that <strong>forecastday</strong> is the array which I need to pull the data out of.</p>
  
  <p>I was also able to get the DATE data to display thats located right before the <strong>forecastday</strong> array:</p>
  
  <pre><code>&lt;cfset fctdate = parsed_json.forecast.txt_forecast.date&gt;
  </code></pre>
  
  <p>This is where I don't really know the best way to get the 7-10 day forecast data out of the JSON array. </p>
  
  <p>Would I have to select an individual result from the JSON array, and define it within the CFSET tag, such as forecastday <strong>period[0]</strong> etc...? Or would I need to use a CFLOOP tag to pull in the results? And if so how would I write the CFLOOP to grab the 7-10 day weather forecast?</p>
  
  <p>Any help would be appreciated. I think I have supplied all the necessary documentation to help resolve this. Let me know if any further clarification is needed or if I missed providing any necessary documentation. Thanks to any and all who assist.</p>