Read and Parse JSON from File

Load a JSON file and parse it into a Python object.

Code

Python
import json

with open("data.json", "r", encoding="utf-8") as f:
    data = json.load(f)

print(data)

Line-by-line explanation

Expected output

{"name": "John", "age": 30}

Related snippets

Related DuskTools