import json def redact_field_names(field_data): for field in field_data: if 'fieldName' in field: field['fieldName'] = 'Redacted' return field_data with open('Downloads/data_new.json', 'r') as file: # Parse the JSON data fieldData = json.load(file)#armbase-b2f7e.appspot.com/o/PaidMonitoredFields%2FqbnmIkSbAwc8TTR5FPnViu2Rr0A2%2F1717151977814%2F20240415%2Fhybrid?generation=1717456080710277&alt=media",#armbase-b2f7e.appspot.com/o/PaidMonitoredFields%2FqbnmIkSbAwc8TTR5FPnViu2Rr0A2%2F1717066732030%2F20240604%2Fhybrid?generation=1717593104205756&alt=media",# redacted_data = redact_field_names(fieldData) # Specify the filename filename = 'data_updated.json' # Open the file in write mode and use json.dump to write the data to the file with open(filename, 'w') as file: json.dump(redacted_data, file, indent=4) # indent=4 for pretty printing print(f"Data has been written to {filename}")