Python: Parse and write JSON
A short, tested Python example for parse and write json. Copy it and adjust the names and paths for your project.
Python
import json
data = json.loads('{"a": 1}') # string -> dict
text = json.dumps(data, indent=2) # dict -> string
with open("data.json") as f:
data = json.load(f) # file -> dict
with open("data.json", "w") as f:
json.dump(data, f, indent=2)Find it in Zest
Search for “python parse and write json” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.