I am trying to delete mutiple information of a json file but I dont know what to do in python to resolve the problem
I tried add() it doesnt work and pop() and i can't make it to work either so what other option is their that I can try
Wondering, if you tried using "del" keyword.
Sample code -
import json
with open('data_file.json', 'r') as file:
data = json.load(file)
keys_to_delete = ['k1', 'k2', 'k3']
for k in keys_to_delete:
if k in data:
del data[k]
with open('new_data.json', 'w') as file:
json.dump(data, file)