Web service support in macros

I was hoping that the ‘open’ function within the macros would allow for opening text from a http source that are not a static text file. In other words if I had a script at https://forum.image.sc/PrintJson.php that simply prints JSON text I would like to be able to parse that within the macro or javascript of ImageJ. The reason this would be helpful is that it would allow for dynamically loading and closing images within ImageJ based on the current output of a web service or WSDL or whatever you want to call it. I would have the macro or javascript within ImageJ call the web service every 10 seconds or so to check for changes to the text. So on first call to the web service it may have a list of three images to open in ImageJ, but after 20 seconds the list changes to one image (in which case I would tell the macro or script within ImageJ to close all existing images and load the news ones specified in the web service).

Not all javascript is supported within ImageJ so I can’t seem to make ajax calls to a web service to read a dynamically generated JSON object or simple text list of images to load. I’m new to ImageJ but I have searched all of the docs and can’t find anything on this topic. Any help would be appreciated.

Maybe use File.openUrlAsString(url) instead.
this, for example, retrieves weather data in json format.

print (f);


Thanks @jerome, I decided to work on a java plugin to solve the problem to give me more options.

1 Like