python create json object

JavaScript
#import the json module
import json 

#create a dictionary which we can add to a json file
dictionary ={ 
    "name" : "sathiyajith", 
    "rollno" : 56, 
    "cgpa" : 8.6, 
    "phonenumber" : "9976770500"
} 

#open an object with following inputs: 'name_of_file.json', 'w'
#dump the content fromt he dictionary into the outfile
with open("sample.json", "w") as outfile: 
    json.dump(dictionary, outfile) # Basic syntax:
import ast
# Create function to import JSON-formatted data:
def import_json(filename):
  for line in open(filename):
    yield ast.literal_eval(line)
# Where ast.literal_eval allows you to safely evaluate the json data.
# 	See the following link for more on this:
# 	https://stackoverflow.com/questions/15197673/using-pythons-eval-vs-ast-literal-eval
        
# Import json data
data = list(import_json("/path/to/filename.json"))

# (Optional) convert json data to pandas dataframe:
dataframe = pd.DataFrame.from_dict(data)
# Where keys become column namesexample={
    "Playlists": [
        "Default"
    ],
    "Default": [
        "Resources\\Media\\C.mp3",
        "Resources\\Media\\K.mp3"
    ]
}
import json
json_file_path=input('Enter the path: ')
with open(json_file_path,'w') as hand:
     json.dumps(example,hand,indent=4) 
'''# dict,file_pointer,indentation'''
    
Source

Also in JavaScript: