Having Trouble Linking to Files for JS in Max

j kuprys's icon

I'm working on a Masters thesis at the moment where I am using javascript to use spectral metadata to compare between files to test for a number of criteria. I'm currently storing the metadata as arrays in local JSON files. I want to be able to link to the local JSON files, but I can't find any proper documentation on the idea bizarrely and I don't know the proper syntax to link to a local file. If anybody could lend a hand with how to link to the files and pull data from them, or even a helpful link, I would much appreciate it!

All the best!

tyler mazaika's icon

I assume by "link to" you just mean read the file? One solution I've used goes roughly like this:

var tmp_dict = new Dict()
tmp_dict.import_json( <filepath.json> )
var json_data = JSON.parse( tmp_dict.stringify() )

j kuprys's icon

Hey Tyler, apologies for the confusion. I meant to read the file, yes. I gave that code a shot just there, it works perfectly! Thank you, and I wish you all the best.