Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
import json from pathlib import Path # Write with open("data.json", "w", encoding="utf-8") as f: json.dump({"users": [{"id": 1, "name": "Alice"}]}, f, indent=2) # Read with open("data.json", encoding="utf-8") as f: data = json.load(f) # Pathlib shortcut data = json.loads(Path("data.json").read_text(encoding="utf-8"))
Result
Open