BookmarkSubscribeRSS Feed
jwebber

Community Trekker

Joined:

Sep 18, 2017

Re: How to parse a JSON file opened from URL?

Thank you all for your replies. I ended up working around this issue by using a VB script to download the .json file from my URL. Initiating the download using VBS was much faster than any method I could find with JMP.

 

Fortunately, I was still able to use JSL for the whole process. I wrote the VB script in JSL, saved the data with a .vbs extension and then issued an open() command from JSL to execute the VB script (which then downloaded my data). 

 

Here's an example of the code I used:

//define static VB script
one="dim xHttp: Set xHttp = createobject(\!"Microsoft.XMLHTTP\!")\!rdim bStrm: Set bStrm = createobject(\!"Adodb.Stream\!")\!r";
two="xHttp.Open \!"GET\!", \!"";
three="\!", False\!r";
four="xHttp.Send\!rwith bStrm\!r.type = 1\!r.open\!r.write xHttp.responseBody\!r";
five=".savetofile \!"C:\users\";
six="\desktop\data.json\!", 2\!rend with";

//define user.name
user.name="jwebber";

//define URL
url=www.somewebaddress.com;

//create full VB script
vbs=concat(one,two,url,three,four,five,user.name,six);

//save VB script
save text file("c:/users/"||user.name||"/desktop/download_data.vbs",vbs);

//open vbs file
open("c:/users/"||user.name||"/desktop/download_data.vbs"); 
Justin_Chilton

Joined:

Aug 27, 2015

Re: How to parse a JSON file opened from URL?

Hi @jwebber,

Glad to hear you were able to find a solution.

One suggestion I would have is to use RunProgram to execute your VBScript file instead of using the Open Function.

Using RunProgram ensures that the script is run on a VBScript host instead of relying on the computer's file association for vbs files (which could potentially be a text editor).

Another benifit of using RunProgram is that you can use the "text" option for the ReadFunction that will pause your JSL script until the VBScript has completed.

Below is some information I previously shared on the JMP Community here.

You can use either the WScript or CScript executables to run a VBScript file using RunProgram. The only difference is that WScript will show errors in a MessageBox, whereas CScript writes the error to the console/stdout.

Here is an example using CScript. 

rp = RunProgram( Executable( "CSCRIPT.EXE" ), Options( "\!"C:\runMe.vbs\!"" ), Read Function( "text" ) );

 

Justin