Answer the question
In order to leave comments, you need to log in
How to fix error when saving file to json?
There is a list of dictionaries [{}, {}, {}, {}...] (in the .json file)
It is necessary to find dictionaries with the same keys and remove duplicates. I do it like this:
with open('file.json') as f:
data = json.load(f)
clean_data = [{x['title']: x for x in data}.values()]
with open("clean_file.json", "w") as file:
json.dump(file, clean_data)
TypeError: Object of type TextIOWrapper is not JSON serializable
Answer the question
In order to leave comments, you need to log in
Read the documentation for the json.dump function and check the order of the parameters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question