How do I write JSON data to a file in Python?

You can use Python module json to write JSON data to a file as shown in the below example –