Now 'data' is a Python dictionary (or list, depending on your JSON structure)

print(data) ```

How it works:

  1. import json: Imports Python's built-in JSON library.
  2. with open(...): Opens the file.
  3. "r" means open in read mode.
  4. encoding='utf-8' is highly recommended to prevent errors with special characters (like emojis or accented letters).
  5. json.load(file): Reads the file and converts the JSON data into a Python dictionary or list.

Other Common Scenarios

1. Reading a JSON String (not a file)

If you already have the JSON data as a string in your code, use json.loads() (the "s" stands for string):

```python import json

json_string = '{"name": "Alice", "age": 30}'