cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
DTDummy99
Level II

Does JSON Parser Add-In need to be available in JMP-Live environment to work on published report?

We recently created JSL code to collect data from a REST API call. I'm currently on version 18.01 of JMP.

Essentially our application developer has created a scenario where for a specific manufacturing dept. we call in the data in "monthly" blocks, to reduce too much "heavy lifting". We cover 24 months of data backwards from today. We then combine each month's data into a data table then perform our analysis on the fully populated data table.

Ultimately, we intend to publish this report to JMP-Live and there-in lies our issue. I did a quick publish to JMP-Live where the REST API call is utilized, however it failed to run, I suspect its due to the JSON Parser Add-In we loaded into JMP.

Per the code below you can see 2 critical lines where the JSON Parser Add-In comes into play...

// Parse JSON and build table
json = JSON:Parse(result);
tempDT = JSON:Make Table(json);

 

Perhaps there is a better way of accomplishing our end results, or do we need to make the JSON Parser Add-In available in the JMP-Live environment?

Best regards,
John



Names Default To Here(1);

// Create empty Combined Results table
finalTable = New Table("Combined Results");

// Loop through month offsets
For(month = 1, month <= 24, month++,

	Try(
		// Build and send request
		request_url = "https://XXXX-XXX.XXXXXXX.net/XXXX/api/xX.X.X./XXX/dept/dt/month_offset/" || Char(month) || "/met_test_results" ;
		result = New HTTP Request(URL(request_url), Method("GET")) << Send;
		
		// Parse JSON and build table
		json = JSON:Parse(result);
		tempDT = JSON:Make Table(json);

		// Append only if rows exist
		If(NRow(tempDT) > 0,

			// Add MonthOffset column
			tempDT << New Column("MonthOffset", Numeric, Set Each Value(month));

			// Append to final table
			finalTable << Concatenate(tempDT, Append to First Table);
			Write("Month " || Char(month) || ": Data added to Combined Results.\n");

		,
			Write("Month " || Char(month) || ": No data returned — skipping.\n");
		);

		// Always close the temp table
		Close(tempDT, NoSave);
	,
		Write("Skipping month offset " || Char(month) || " due to error or bad response.\n");
	);
	Wait (0.25) ;
);

// Show final table if it has any rows
If(NRow(finalTable) > 0,
	finalTable << Set Name("Combined Results");
	finalTable << Show Window,
	New Window("No Data", Text Box("No valid data returned from selected months."))
);

// Assuming finalTable is already your active data table
dt = finalTable;
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Does JSON Parser Add-In need to be available in JMP-Live environment to work on published report?

Have you looked at JSON to Data Table()?

result = "\[[
 {
  "name" : "KATIE",
  "age" : 12,
  "sex" : "F",
  "height" : 59,
  "weight" : 95
 },
 {
  "name" : "LOUISE",
  "age" : 12,
  "sex" : "F",
  "height" : 61,
  "weight" : 123
 },
 {
  "name" : "LAWRENCE",
  "age" : 17,
  "sex" : "M",
  "height" : 70,
  "weight" : 172
 }
]]\";
dt = JSON to Data Table( result );

mmarchandFSLR_0-1743612925303.png

 

View solution in original post

2 REPLIES 2

Re: Does JSON Parser Add-In need to be available in JMP-Live environment to work on published report?

Have you looked at JSON to Data Table()?

result = "\[[
 {
  "name" : "KATIE",
  "age" : 12,
  "sex" : "F",
  "height" : 59,
  "weight" : 95
 },
 {
  "name" : "LOUISE",
  "age" : 12,
  "sex" : "F",
  "height" : 61,
  "weight" : 123
 },
 {
  "name" : "LAWRENCE",
  "age" : 17,
  "sex" : "M",
  "height" : 70,
  "weight" : 172
 }
]]\";
dt = JSON to Data Table( result );

mmarchandFSLR_0-1743612925303.png

 

DTDummy99
Level II

Re: Does JSON Parser Add-In need to be available in JMP-Live environment to work on published report?

That suggestion worked great in the JMP desktop app, thanks for assisting.

However, it failed to refresh with same script as desktop app in the JMP-Live environment. More work to do unfortunately!

Recommended Articles