29 lines
797 B
Python
29 lines
797 B
Python
import json
|
|
import sys
|
|
|
|
def remove_note_objects(obj):
|
|
if isinstance(obj, list):
|
|
return [remove_note_objects(item) for item in obj if not (isinstance(item, dict) and item.get("result") == "NOTE")]
|
|
elif isinstance(obj, dict):
|
|
return {k: remove_note_objects(v) for k, v in obj.items()}
|
|
return obj
|
|
|
|
def main():
|
|
if len(sys.argv) != 3:
|
|
print("Usage: python remove_notes.py <input_file.json> <output_file.json>")
|
|
sys.exit(1)
|
|
|
|
input_file = sys.argv[1]
|
|
output_file = sys.argv[2]
|
|
|
|
with open(input_file, 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
cleaned_data = remove_note_objects(data)
|
|
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
json.dump(cleaned_data, f, indent=4)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|