I have about 500 json files with comments in them. Trying to update a field on the json file with a new value, throws an error. I managed to use commentjson to remove strings like this // some text and the json file updates and throws no errors.
But there is about 100 json files with comments like this:
/*
1. sometext.
i. sometext
ii. sometext
2. sometext
*/
Commentjson just crashes when /* exists. If I remove /* and run the code, it will work and update and remove any //. How can I write some code to manage /* and all text between /* */?
This is my current code that can remove //
with open(f"{i['Location']}\\{file_name}",'r') as f:
json_info = commentjson.load(f) #Gets info from the json file
json_info['password'] = password
with open(f"{i['location_Daily']}\\{file_name}",'w') as f:
commentjson.dump(json_info,f,indent = 4) #updates the password
print("updated")