Courseiva
Data SerializationhardMultiple ChoiceObjective-mapped

JNCIA-DevOps Data Serialization Practice Question

When writing a Python script to interact with a Junos device via PyEZ, you receive an object representing RPC output. You want to serialize a custom Python class instance containing device metadata into JSON, but calling json.dumps() raises a TypeError. What is the standard approach to resolve this?

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

Pass a custom serialization function to the 'default' parameter in json.dumps().

The json module does not know how to serialize custom Python object instances by default. You must provide a custom serialization function and pass it to the 'default' parameter of json.dumps().

Answer analysis

Option-by-option breakdown

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

  • Pass a custom serialization function to the 'default' parameter in json.dumps().

    Why this is correct

    Correct. The 'default' parameter accepts a function that is called for objects that can't otherwise be serialized.

  • Use yaml.safe_dump() instead, which natively serializes all custom Python classes.

    Why it's wrong here

    Incorrect. yaml.safe_dump() also cannot arbitrarily serialize custom Python classes without custom representers.

  • Convert the object into an XML string before calling json.dumps().

    Why it's wrong here

    Incorrect. json.dumps() accepts strings, not raw XML trees.

  • Modify the global sys.path variable to include the custom class definition.

    Why it's wrong here

    Incorrect. sys.path controls module imports, not object serialization.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This JNCIA-DevOps question is part of Courseiva's 306-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 August 2026 · checked against the official Juniper Networks exam blueprint

This JNCIA-DevOps practice question is part of Courseiva's free Juniper Networks 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 JNCIA-DevOps exam.