Junior Codes
The Sky Expedition · stretch

JSON in Python for Kids

Turn dictionaries and lists into text that any program can read.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

JSON, explained simply

Programs often need to pass information to each other: a game saves its progress, a weather app downloads today’s forecast. JSON is a common text format for doing that.

JSON looks almost exactly like Python dictionaries and lists, which makes it easy to learn. The json module converts between the two.

json.dumps() turns a Python value into a JSON string, and json.loads() turns a JSON string back into Python. json.dump() and json.load() do the same directly with files.

Example: Pack a message

import json

explorer = {"name": "Meera", "badges": 4}
text = json.dumps(explorer)
print(text)
back = json.loads(text)
print(back["badges"] + 1)

Output

{"name": "Meera", "badges": 4}
5

Try this

  • Save a dictionary of your favourite things to a .json file with json.dump.
  • Write JSON by hand as a string and load it into a dictionary.
  • Look at the difference between True in Python and true in the JSON text.

Practise it in Wonderwild

“Messages between machines”

Mission 33 in The Sky Expedition, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

What does JSON stand for?+

JavaScript Object Notation. It started in JavaScript but almost every programming language can read and write it now.

Is JSON the same as a Python dictionary?+

No. A dictionary lives in your running program; JSON is text. They look similar, which is why converting between them is simple.

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course