JNCIA-DevOps Data Serialization Practice Question
A Python script retrieves interface statistics from a Junos device in JSON format, modifies a threshold value, and needs to output it back into a formatted JSON string with an indentation level of 4 spaces for readability. Which Python snippet achieves 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
✓
json.dumps(data, indent=4)
The json.dumps() method accepts an 'indent' parameter which specifies the number of spaces to use for pretty-printing the resulting JSON string.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
json.format(data, spacing=4)
Why it's wrong here
Incorrect. There is no 'format' method in the standard Python json module.
- ✓
json.dumps(data, indent=4)
Why this is correct
Correct. json.dumps() serializes a Python object to a JSON formatted string using an indentation of 4 spaces.
- ✗
json.dump(data, indent=4)
Why it's wrong here
Incorrect. json.dump() requires a file-like object as its second positional argument, whereas json.dumps() returns a string.
- ✗
json.stringify(data, spaces=4)
Why it's wrong here
Incorrect. stringify is a JavaScript method, not a Python json module function.
About these practice questions
This JNCIA-DevOps question is part of Courseiva's 307-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 →
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.