We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a03c8dc commit 1efbf92Copy full SHA for 1efbf92
docs/cheatsheet/json-yaml.md
@@ -12,7 +12,7 @@ JSON stands for JavaScript Object Notation and is a lightweight format for stori
12
```python
13
>>> import json
14
>>> with open("filename.json", "r") as f:
15
-... content = json.loads(f.read())
+... content = json.load(f)
16
```
17
18
Write a JSON file with:
@@ -22,7 +22,7 @@ Write a JSON file with:
22
23
>>> content = {"name": "Joe", "age": 20}
24
>>> with open("filename.json", "w") as f:
25
-... f.write(json.dumps(content, indent=2))
+... json.dump(content, f, indent=2)
26
27
28
## YAML
0 commit comments