I have a JSON master config file whose value may be overwritten by a specific account’s config file (also in JSON). The Master file has this structure:
{
"section1Configs": {
"setting01": true,
"setting02": true,
"setting03": false
},
section2Configs: {
"setting01": true,
"setting02": true,
"setting03": false
},
section3Configs: {
"setting01": true,
"setting02": true,
"setting03": false
},
section4Configs: {
"setting01": true,
"setting02": true,
"setting03": false
}
}
The config file for a specific account may look like this:
{
"section1Configs": {
"setting01": true,
"setting02": true,
"setting03": true
},
section2Configs: {
"setting01": false,
"setting02": true,
"setting03": false
},
section3Configs: {
"setting01": true,
"setting02": false,
"setting03": false
},
section4Configs: {
"setting01": true,
"setting02": true,
"setting03": false
}
}
Note that they are identical except certain values (section01Config.setting03, section02Config.setting01, and section03Config.setting02) are different. Note also that the entire section4Configs block is the same in both files.
The ones that are the same are not needed since the application loads both and overwrites the Master file with the ones that are different in the account config.
What I would like to do is have a script that iterates through a directory of such account files and deletes the entry in each file that are the same key and value as the Master file. From this example I would end up with a file like this:
{
section1Configs: {
setting03: true
},
section2Configs: {
setting01: false
},
section3Configs: {
setting02: false
}
}
There are over 200 account config files and doing this manually will take a lifetime. Any help is greatly appreciated!
—— EDIT ——-
I tried to keep the question simple but I think a missing detail will have an impact on the answer.
The account and config JSON file consist of sections and their corresponding settings. This means that the JSON is one level deeper than what’s mentioned above:
{
"section1Configs": {
"level1Settings": {
"section01Lev01_01": true,
"section01Lev01_012": true,
"section01Lev01_02": true
}
}
}
Thanks!