parse json response

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
G_Allen

parse json response

19 Aug 2017, 00:23

Code: Select all

jsonGet(s,k){
	static o:=comobjcreate("scriptcontrol")
	o.language:="jscript"
	return o.eval("(" s ")." k)
}
;Response from WinHTTPRequest~  {"Response":{"creditBalance":"916","number":"4178613971","carrier_type":"mobile","carrier":"AT&T"}} 
;string={"Response":{"creditBalance":"916","number":"4178613971","carrier_type":"mobile","carrier":"AT&T"}}
;msgbox,% jsonGet(string,"creditBalance")
;msgbox,% jsonGet(string,"number")
;msgbox,% jsonGet(string,"carrier")
; doesn't work

string={"creditBalance":"916","number":"4178613971","carrier_type":"mobile","carrier":"AT&T"}
msgbox,% jsonGet(string,"creditBalance")
msgbox,% jsonGet(string,"number")
msgbox,% jsonGet(string,"carrier")
;works

;How do I get just the "Response" value inside the inner {} of the ResponseText so that I can get the data I need?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], lmstearn, roeleboele and 378 guests