Template request | Bug report | Generate Data Product
Tags: #python #json #file #save #data #io
Author: Sriniketh Jayasendil
Description: This notebook will demonstrate how to save a json file using Python.
References:
import json
data
: a dictionary containing the data to be saved in the json filejson_path
: json file path
data = {"name": "John Doe", "age": 30, "city": "New York"}
json_path = "data.json"
Using the json.dump()
function, the data
dictionary can be saved to a json file.
with open(json_path, "w") as f:
json.dump(data, f)
print("The json file has been saved to the current directory.")