CLOSE ALL
CLEAR ALL
CLEAR

SET PROCEDURE TO qdfoxJSON
JSONStart()

* Yahoo use doubleqoutes for string delimitation while qdfoJSON use single quotes by default. 
JSON.stringDelimitator = ["]


?"JSON Test #5"
?"Version " + JSON.Version
?
?"THIS TEST SHOWS HOW TO USE PARSE THE RESPONSE FROM A URL RETURNING JSON DATA"
?
?"Calling URL and parsing the response..."
LOCAL oWFC
oWFC = JSONObject("url:http://weather.yahooapis.com/forecastjson?w=2502265")
??"Done!"

?
?"Weather forecast for:"
  ?"",oWFC.Location.City + ", " + oWFC.Location.State_Abbreviation + " (" + oWFC.Location.Country_Abbreviation + ")"
  ?
FOR i = 1 TO oWFC.Forecast.Count
 oFC = oWFC.Forecast[i]
 ?"",oFC.Day
 ?"","","Condition:",oFC.Condition
 ?"","","Highest:",oFC.high_Temperature + oWFC.Units.Temperature
 ?"","","Lowest:",oFC.low_Temperature + oWFC.Units.Temperature 
ENDFOR 

?"Wind:"
  ?"","Speed:",ALLTRIM(STR(oWFC.Wind.Speed,3))+oWFC.Units.Speed
  ?"","Direction:",oWFC.Wind.Direction
?"Atmosphere:"
  ?"","Humidity:",oWFC.Atmosphere.Humidity
  ?"","Visibility:",oWFC.Atmosphere.Visibility + oWFC.Units.Distance
  ?"","Pressure:",oWFC.Atmosphere.Pressure + oWFC.Units.Pressure
  ?"","Rising:",oWFC.Atmosphere.Rising
?"Astronomy:"
?"","Sunrise:",oWFC.Astronomy.Sunrise
?"","Sunset:",oWFC.Astronomy.Sunset  
 
?
?"Test completed"
?
?"For more information, read initial comments at qdfoxJSON.PRG file"

RETURN


*!* Yahoo Weather API Response Structure
*!*
*!*	Units
*!*	 .Temperature 
*!*	 .Speed 
*!*	 .Distance 
*!*	 .Pressure 
*!*	Location
*!*	 .location_id
*!*	 .city
*!*	 .state_abbreviation
*!*	 .country_abbreviation
*!*	 .elevation
*!*	 .latitude
*!*	 .longitud
*!*	Wind
*!*	 .Speed
*!*	 .Direction
*!*	Atmosphere
*!*	 .Humidity
*!*	 .Visibility
*!*	 .Pressure
*!*	 .Rising
*!*	Url
*!*	Logo
*!*	Astronomy 
*!*	 .Sunrise
*!*	 .Sunset
*!*	Condition
*!*	 .Text
*!*	 .Code
*!*	 .Image
*!*	 .Temperature
*!*	ForeCast[] 
*!*	 .Day
*!*	 .Condition
*!*	 .High_Temperature
*!*	 .low_Temperature


