Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Parse Decode Read JSON Data MSScriptControl.ScriptControl Eval Javascript
#DefineFunction JSONGET ( JSON_Data, JSON_Return ) If StrLen(JSON_Data) > 0 Then var = "function do_json()" : @CRLF var = var:"{" : @CRLF var = var: "var myJSONObject = {""x"": " : JSON_Data : " };" : @CRLF var = var: "return myJSONObject.x." : JSON_Return : ";" : @CRLF var = var:'}':@CRLF oScript=CreateObject("MSScriptControl.ScriptControl") oScript.language = "javascript" oScript.addcode(var) Ret = oScript.Eval(StrCat("do_json()") ) oScript=0 Return Ret Else Return "*ERROR*" EndIf #EndFunction ;http://gomashup.com/cms/usa_zipcode_json stateabrv = "WA" cURL="http://gomashup.com/json.php?fds=geo/usa/zipcode/state/":stateabrv oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") oHTTP.Open("GET", cURL, @FALSE) oHTTP.Send() oHTTP.WaitForResponse() JSON_Data = oHTTP.ResponseText Pause("JSON DATA",JSON_Data) c = JSONGET(JSON_Data, "result.length") For x = 1 To c node = x-1 yourcity = JSONGET(JSON_Data, "result[":node:"].City") yourzip = JSONGET(JSON_Data, "result[":node:"].Zipcode") yourlong = JSONGET(JSON_Data, "result[":node:"].Longitude") yourlat = JSONGET(JSON_Data, "result[":node:"].Latitude") Pause("Zip Codes- Node ": node,"City = ": yourcity :@CRLF :"Zipcode = ": yourzip :@CRLF :"Longitude = ": yourlong :@CRLF :"Latitude = ": yourlat) Next x oHTTP=0 Exit
Article ID: W18211
Filename: Parse JSON Using Eval.txt
File Created: 2012:04:18:11:34:52
Last Updated: 2012:04:18:11:34:52