How can I load and work with JSON config file during install time? I can read string from file and write it, but if I want to change some value in config file, I have to use VBScript.RegExp
COM object (which is good, but painful and slow to develop).
Current method:
ExtractTemporaryFile('config.json');
filename := ExpandConstant('{tmp}\config.json');
LoadStringFromFile(filename, conf);
objRegExp := CreateOleObject('VBScript.RegExp');
objRegExp.Pattern := 'test';
conf := objRegExp.Replace(conf, 'test_replace');
SaveStringToFile(filenameOut, conf, False);
Is there a better way to do this? All I need is to replace some values in JSON object, no extra magic.
I've setup the new project called
Inno JSON Config
, which allows you to work with simple JSON config files like shown below and which allows you to read and write string, integer and boolean values:The usage is quite straightforward (even when I'm going to add handle support as well). Note, that only Unicode Inno Setup (in one of the most recent versions due to a required
Int64
support) can be used: