Example of accessing data
print("\nAccessing specific data:") print("Name:", data['name']) print("First skill:", data['skills'][0])
---
### Step-by-Step Explanation
Let's break down the code above with a complete, runnable example.
#### 1. Create a Sample JSON File
First, let's create a JSON file to read. Save the following content in a file named `data.json` in the same directory as your Python script.
**`data.json`**
```json
{
"name": "Alex",
"id": 12345,
"is_active": true,
"email": null,
"skills": [
"Python",
"Data Analysis",
"Machine Learning"
],
"projects": {
"project_a": "In Progress",
"project_b": "Completed"
}
}
Note: JSON requires double quotes
"for all keys and string values. Single quotes'will cause an error.
2. Write the Python Script
Now, let's look at the Python code in detail.
read_file.py
```python
