Login  Register

Using JSON files in Macros

Posted by Kirmse, Robert on Aug 22, 2017; 7:00am
URL: http://imagej.273.s1.nabble.com/Using-JSON-files-in-Macros-tp5019247.html

Dear ImageJ List,
I have a question regarding the use of JSON files.

I would like to use a JSON file for storing settings/parameter for a macro.
However I am not sure how to use the variable in the actual macro once I read it.

So the way I tried to set it up is the following


javascript file that reads the JSON with.

...
function read JSON() {
var settings = JSON.parse(IJ.openAsString("pathToFile\\inputs.json"));
"some more code"
return(settings)
}

--------------------
and then my actual IJM file
"some code"

javacode = File.openAsString("pathToFile\\JSON_Read2.js");
settings= eval("script",javacode);


that only give the message "object array" in the log file, when I try to access settings.
I tried storing the retrieved JSON content in different variables that i tried to return but was not successfull.

I am wondering if there is an elegant way to actually get the JSON content and make them
available for the imageJ macro.

Thank you in advance for any hints

Best
Rob

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html