Standard Library · 8 min read · Beginner
JSON & the Python Standard Library
Work with JSON APIs using json.dumps/loads, count frequencies effortlessly with collections.Counter, and format dates with datetime.
What you'll learn
- Serialize and parse JSON cleanly using json.dumps() and json.loads()
- Count occurrences in one line with collections.Counter
Python ships “batteries included”. Three standard-library modules you will reach for constantly are json, collections.Counter, and datetime.
Fill-in-the-Blank Exercise
JSON Serialization & Counter
Serialize a dictionary to JSON text and count track frequencies with Counter.
import json
from collections import Counter
text = json.({"track": "Python", "free": True})
counts = (["HTML", "SQL", "HTML", "Python"])Try It Yourself
Pythonjson + Counter + date
Python Output (WebAssembly / Pyodide)
Click Run Python to execute real Python 3 right in your browser.
Check Your Understanding
Score: 0 / 1
1. Which function parses a JSON string into a Python dictionary or list?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.