extract json data in livecode -


i apologies, new in livecode , have no coding experience. trying extract wunderground hourly json data in livecode, can't

json data:

"response": {    "version":"0.1",    "termsofservice":"http://www.wunderground.com/weather/api/d/terms.html",    "features": {    "hourly": 1    }  	}  		,  	"hourly_forecast": [  		{  		"fcttime": {  		"hour": "12","hour_padded": "12","min": "00","min_unpadded": "0","sec": "0","year": "2017","mon": "9","mon_padded": "09","mon_abbrev": "sep","mday": "12","mday_padded": "12","yday": "254","isdst": "0","epoch": "1505196000","pretty": "12:00 pm +06 on september 12, 2017","civil": "12:00 pm","month_name": "september","month_name_abbrev": "sep","weekday_name": "tuesday","weekday_name_night": "tuesday night","weekday_name_abbrev": "tue","weekday_name_unlang": "tuesday","weekday_name_night_unlang": "tuesday night","ampm": "pm","tz": "","age": "","utcdate": ""  		},  		"temp": {"english": "85", "metric": "29"},  		"dewpoint": {"english": "77", "metric": "25"},  		"condition": "thunderstorm",  		"icon": "tstorms",  		"icon_url":"http://icons.wxug.com/i/c/k/tstorms.gif",  		"fctcode": "15",  		"sky": "75",  		"wspd": {"english": "4", "metric": "6"},  		"wdir": {"dir": "s", "degrees": "185"},  		"wx": "thunderstorms",  		"uvi": "11",  		"humidity": "77",  		"windchill": {"english": "-9999", "metric": "-9999"},  		"heatindex": {"english": "94", "metric": "35"},  		"feelslike": {"english": "94", "metric": "35"},  		"qpf": {"english": "0.03", "metric": "1"},  		"snow": {"english": "0.0", "metric": "0"},  		"pop": "61",  		"mslp": {"english": "29.78", "metric": "1008"}  		}  		,

i copied easyjson https://github.com/luxlogica/easyjson stackscript. , button code looks this:

on mouseup     put text of fld "city" tcityname     put text of fld "country" tcountry            put "http://api.wunderground.com/api/dfabb014e63a7457/hourly/q/" &tcountry&"/"&tcityname& ".json" turl  put url turl trawjson  put textdecode(trawjson,"utf8") fld "weatherdata"  put arrayfromjson(trawjson) tarray    put tarray["fcttime"]["temp"] fld "temp"    end mouseup

in version 8 , above there json library included in livecode, includes 2 commands: jsonimport , jsonexport. jsonimport converts json encoded data array.

put text of fld "city" tcityname put text of fld "country" tcountry put "http://api.wunderground.com/api/dfabb014e63a7457/hourly/q/" &tcountry&"/"&tcityname& ".json" turl put url turl trawjson put textdecode(trawjson,"utf8") fld "weatherdata" put jsonimport(fld "weatherdata") tarray put keys of tarray fld "temp" 

there handy tree view widget in v. 8 , higher makes easy visualize contents of array. drag tree view widget onto card tools palette , this:

set arraydata of widget "tree view" tarray 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -