liveBook · Manning

Json.load

As explained in A Pythonic Adventure: From Python basics to a working web app

The Python json.load function reads JSON from a file-like object and deserializes it into a Python value.

Need yesterday’s coffee orders? Open the JSON file for reading, hand the file object to json.load(), and store the returned Python value. section 8.0

Read saved orders

import json f = open("orders.json", "r") saved_orders = json.load(f) print(saved_orders)

The small recipe is:

  • Open the JSON file in reading mode. section 8.0
  • Pass the file object to json.load(). section 8.0
  • Assign the returned value, such as a list of order dictionaries, to a variable. section 8.0

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Explains the file-reading sequence and returned value, stopping short of deeper JSON internals.
Examples
Uses orders.json, saved_orders, and a printed list of coffee-order dictionaries.
What it assumes
Assumes basic Python variables and file opening while introducing the json module and JSON file workflow.
What you can do after
Apply json.load() to read a JSON file and recover its stored Python value.
How it connects
Connects JSON, file objects, Python lists, dictionaries, and json.dump().

Also explained in

Compare how 3 books explain json.load →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.