Jan-24-2020, 04:45 PM
I have a script where the users will need to edit some variables. I don't want them to mess the script up so decided I would make a config json file where they could just edit the json rather than edit the script.
I don't want the users to have to understand \\, I want them to fill it in the way you would normally type a file path or domain user account. The problem is I get a json.decoder.JSONDecodeError: Invalid \uXXXX escape: line 5 column 22 (char 243) error. I understand why this is, but is there a way I can make it easy for the user, and Python ignore the error. Once I have parsed the JSON I will sort out the paths so Python can understand them.
{
"ClientID":"8477295f-405",
"ClientSecret":"10f35a425670847eb63d9b1954592d2b8305cd87e3",
"ReportName":"Unprotected_Machines_",
"ReportFilePath":"c:\users\accounts\desktop\reports\",
"ConsoleName":"UK PS",
"SearchDomain":"dc=domain,dc=co,dc=uk",
"SearchUser":"domain\dap.l",
"SearchUserPassword":"password",
"DomainController":"10.0.1.20"
}
I don't want the users to have to understand \\, I want them to fill it in the way you would normally type a file path or domain user account. The problem is I get a json.decoder.JSONDecodeError: Invalid \uXXXX escape: line 5 column 22 (char 243) error. I understand why this is, but is there a way I can make it easy for the user, and Python ignore the error. Once I have parsed the JSON I will sort out the paths so Python can understand them.
def read_json_config(): with open('console_config.json') as json_data: json_config_file = json.load(json_data)This is my JSON file.
{
"ClientID":"8477295f-405",
"ClientSecret":"10f35a425670847eb63d9b1954592d2b8305cd87e3",
"ReportName":"Unprotected_Machines_",
"ReportFilePath":"c:\users\accounts\desktop\reports\",
"ConsoleName":"UK PS",
"SearchDomain":"dc=domain,dc=co,dc=uk",
"SearchUser":"domain\dap.l",
"SearchUserPassword":"password",
"DomainController":"10.0.1.20"
}