Loop through the list of skills

print("\nSkills:") for skill in data['skills']: print("-", skill) ```

How JSON Types Map to Python Types

When you use json.load(), the data is converted as follows:

JSON Python
object dict
array list
string str
number (int) int
number (real) float
true True
false False
null None

Common Issues and Solutions

  1. FileNotFoundError: This happens if Python can't find your file.

    • Solution: Make sure the file name is spelled correctly and the file is in the same directory as your script. If it's in a different directory, provide the full or relative path (e.g., 'data/my_file.json').
  2. json.JSONDecodeError: This means your file is not valid JSON.

    • Solution: Check your .json file for syntax errors. The most common mistakes are:
      • Using single quotes (') instead of double quotes (").
      • Having a trailing comma after the last item in an object or list.
      • Missing commas between elements.
  3. Character Encoding Issues: If your file contains special characters (like é or ü), you might get a UnicodeDecodeError.

    • Solution: Specify the encoding when opening the file. UTF-8 is the most common and is standard for JSON. python with open('data.json', 'r', encoding='utf-8') as file: data = json.load(file)

Reading a JSON String vs. a JSON File

It's important to know the difference between json.load() and json.loads().

  • json.load(): Reads from a file object.
  • json.loads(): Reads from a string. (The 's' stands for "string").

Example using json.loads():

```python import json

json_string = """ { "name": "Brenda", "city": "New York" } """