JSON serialization
Learn in depth →JSON represents a restricted set of data types; dumps produces text and loads parses it.
json.dumps(value); json.loads(text)Example
import json
text = json.dumps({"ok": True, "items": [1, 2]}, sort_keys=True)
print(text)
print(json.loads(text)["ok"])Result
{"items": [1, 2], "ok": true}
TrueWatch for: JSON object keys are strings. Python-specific types need an explicit representation; parsing is not schema validation.
Practise this topic →