Codington
0 of 6 problems solved • 0%

Exercise prompt

Encode a Bookmark

Python dictionaries can contain numbers and booleans. A JSON encoder takes care of quoting text and converting True and False.

Example

A JSON round trip shows which Python types survive encoding.

import json text = json.dumps(["café", True, 4]) values = json.loads(text) print(values[1], type(values[2]).__name__) # True int

Pass booleans and numbers to the encoder in their original types. The encoder handles spelling and quoting.

Your task

Implement bookmark_json(title, page, finished). Return JSON text with exactly those three named fields. Keep their types. The spacing and field order are up to you.

bookmark_json("Tides", 12, False) # '{"title": "Tides", "page": 12, "finished": false}'