Demo: Using an external Custom-JSON-Config-File for convenient parameterization of experiments (Online/Offline)

Hi all,

I wanted to share a small convenience code example to allow an external parameterization of online and offline experiments by using an JSON-File. You can use this JSON-File to avoid regeneration of Py/JS-Files through the builder e.g. during Layout related fine-tuning in Local-Debug (“moving a text-component to desired position”). Furthermore it allows you to have specific config files loaded in e.g. different conditions, resulting in variants of one main experiment. I tried to make it work in Python and JavaScript/Pavlovia experiments.
Accessing the cfg-Variable by using indexing logic (cfg[“paramter”], nested: cfg[“paramtergroup”][“paramter”]), seems to work fine in both worlds (online/offline).

You can use the content of the cfg-Variable in any component:

Using external Config-Files in Python-PsychoPy is relatively common. For Online-Experiments it was a little tricky for me to ensure reliable loading of the Config-File from its ArrayBuffer.

The JSON-File of this demo looks like this.
Config.JSON

{
	"textSize":         0.015,
	"stimulusSize":	 	[0.1,0.2],
	"ErrorMessages":	{
		"Correct": 		"Correct Response! Great!",
		"Wrong": 		"Wrong Answer! Be careful!",
		"LateResponse": "You are too slow!"
	}
}

If you find any errors (e.g. Browser-compatibility), Please file an issue in the Gitlab-Repository.

Demo: useOfConfigFile [PsychoPy] (Using Builder v2022.1.1)
Gitlab: Luke Boelling / configFileDemo · GitLab