Thanks to both Jarmo and Jim, both those solutions work. I initially used Jim's solution, which was able to plug directly into what I initially had. After some revision, I adapted Jarmo's idea which indeed was tidier to manage. Here is what I ended up with. With this setup I didn't need the namespace, but it would still work with namespaces.
names default to here (1);
//initialize variables
var1 = {"a", "b", "c"};
var2 = 100;
var3 = [1, 2, 3, 4];
//initialize variables used for functions
VarsToExport = {"var1", "var2", "var3"};
SettingsAA = Associative Array();
loaded_settingsAA = .;
SelfPath = Get Default Directory();
//expr to get each variable in the VarsToExport list and input the value into an AA, export as JSON
ExportVarsExpr = expr(
for each({varname}, VarsToExport,
//show(varname);
SettingsAA[varname] = eval(as name(varname));
//show(SettingsAA);
);
VarsSavePath = Pick File(
"Save a file containing current script settings",
SelfPath,
{"JMP Script Files|jsl", "All Files|*"},
1,
1,
"Layer_Settings.jsl"
);
Save Text File(VarsSavePath, As JSON Expr(settingsAA));
);
//expr open a jsl file, parse JSON into an AA and extract saved values
ImportVarsExpr = expr(
VarsImportPath = Pick File(
"Select jsl file that contains the saved parameters",
SelfPath,
{"JMP Script Files|jsl", "All Files|*"},
1,
0,
""
);
loaded_settingsAA = Parse JSON(Load Text File(VarsImportPath));
//for each element of AA, get the name of the element and set a variable with that name to the AA value
for each({varname}, loaded_settingsAA,
eval(parse(Evalinsert("\[ "^varname^"n = loaded_settingsAA << get value (varname) ]\")));
//show(varname);
//show(loaded_settingsAA << get value (varname));
);
);
//show original variables
Write("\!N", "Original:");
show(var1, var2, var2);
//export variables
eval(ExportVarsExpr);
//clear the variables
var1 = .;
var2 = .;
var3 = .;
Write("\!N", "\!N", "Variables cleared:");
show(var1, var2, var2);
//import variables
eval(ImportVarsExpr);
//show that the variables have been imported
Write("\!N", "\!N", "Post loading:");
show(var1, var2, var2);