1#import the json module
2import json
3
4#create a dictionary which we can add to a json file
5dictionary ={
6 "name" : "sathiyajith",
7 "rollno" : 56,
8 "cgpa" : 8.6,
9 "phonenumber" : "9976770500"
10}
11
12#open an object with following inputs: 'name_of_file.json', 'w'
13#dump the content fromt he dictionary into the outfile
14with open("sample.json", "w") as outfile:
15 json.dump(dictionary, outfile)