Courseiva

200-901 Software Development and Design Practice Question

A developer needs to read a JSON configuration file and parse it into a Python dictionary. The file contains nested objects. Which code snippet correctly accomplishes this?

⚠ Common exam trap

It's easy for candidates to confuse json.load() (file object) with json.loads() (string), and json.dumps() (serialize) with json.loads() (deserialize) — the 's' and 'dump/load' directionality trips up candidates under time pressure.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

with open('config.json', 'r') as f: data = json.load(f)

json.load() reads directly from a file object and deserializes the JSON content into a Python dictionary, which is exactly what is needed here. The 'with open(...)' context manager ensures the file is properly closed after reading. This combination handles nested objects natively because json.load() recursively parses the entire JSON structure.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    with open('config.json', 'r') as f: data = json.loads(f)

    Why it's wrong here

    json.loads() expects a JSON string, but f is a file object, so it raises TypeError. It is tempting because loads() is the standard parsing call; however, json.load(f) reads and parses the file object directly, which is what this scenario requires.

  • ✗

    data = json.loads(open('config.json', 'r').read())

    Why it's wrong here

    This snippet works, but it leaks the file handle because open() is never closed, unlike a with block. It is tempting because it is compact and parses correctly; however, the question asks for the correct snippet, and the context-manager form guarantees the file is closed.

  • ✓

    with open('config.json', 'r') as f: data = json.load(f)

    Why this is correct

    json.load() deserialises a file object directly into Python dictionaries and lists, recursively handling nested objects. Reading with open() in text mode supplies the required stream, satisfying the stem's nested-JSON parsing requirement without manual string handling.

  • ✗

    with open('config.json', 'r') as f: data = json.dumps(f.read())

    Why it's wrong here

    json.dumps serialises a Python object to a JSON string, so passing f.read() (already a string) returns a quoted string, not a dictionary. It is tempting because dumps and loads are easily confused, but loads parses JSON text into Python objects — the correct choice here.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.