Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

1 matching syntax entry

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}
True

Watch for: JSON object keys are strings. Python-specific types need an explicit representation; parsing is not schema validation.

Practise this topic →
Complete explanation index (91 lessons indexed)

JSON, and the Types It Cannot Hold

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.