JSON Basics

You can use JSON to output a dictionary so it is easier to read, personally i prefer the pprint output but as today i didn’t got a chance to see why i would use that.
so to be updated soon i guess,

so from a Python Script to create a JSON file :
import json

dict_var = { a dictionary }

with open(“dict_var”, “w”) as f:
….json.dump(dict_var, f, indent=4)

so from a Python Script to load a JSON file :

import json

filename = “json_file.json”
with open(filename) as f:
…. json_output = json.load(f)

pprint(json_output)

 

 

Leave a Comment