Courseiva
Data SerializationhardMultiple ChoiceObjective-mapped

JNCIA-DevOps Data Serialization Practice Question

You are writing a Python automation script that processes configuration data. The script reads a YAML file containing Junos firewall filters, modifies them, and writes them back out. However, you notice that all the original comments in the file are stripped out in the output. What is the fundamental reason for this behavior in standard PyYAML dump operations?

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

Comments are stripped during parsing because they are not part of the YAML data model.

PyYAML parses YAML files into abstract syntax trees (AST) or Python native data structures, discarding comments during the parsing phase because comments are not part of the data model.

Answer analysis

Option-by-option breakdown

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

  • The yaml.safe_dump() function explicitly deletes comments for security reasons.

    Why it's wrong here

    Incorrect. Comment removal is due to parser architecture, not security.

  • Comments are stripped during parsing because they are not part of the YAML data model.

    Why this is correct

    Correct. Parsers drop comments since data structures only contain keys, values, and sequence items.

  • YAML specification mandates that all comments are ephemeral and cannot be serialized.

    Why it's wrong here

    Incorrect. Round-trip parsers like ruamel.yaml can preserve comments, proving they are serializable under specific libraries.

  • Comments must be re-injected using the 'preserve_comments=True' parameter.

    Why it's wrong here

    Incorrect. PyYAML does not have a preserve_comments parameter.

About these practice questions

One of 307 original JNCIA-DevOps practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.