json Module
noun
say it: “JAY-sun MOJ-ool” /ˈdʒeɪsən ˈmɒdʒuːl/
Python's standard module for turning dictionaries and lists into JSON text and back, with json.dumps, json.loads, json.dump and json.load.
What is the json module?
The json module turns Python dictionaries and lists into JSON text and back. JSON is the format most websites and apps use to send data.
import json
order = {"item": "pizza", "qty": 2}
text = json.dumps(order)
print(text) # {"item": "pizza", "qty": 2}
print(json.loads(text)["qty"]) # 2
In a sentence
- “json.loads, from the json module, turned the API's text back into a dictionary.”
- “The json module saved the orders to orders.json.”
Level: Journeyman · More Python terms at this level
Updated