200-901 exam dumps

200-901 practice question 34 of 204

Cisco DevNet Associate. Associate level, Cisco. Free question with the correct answer and a full explanation.

200-901 Question 34

Select 3

A developer is tasked with creating a Python script to identify configuration differences between two JSON files, 'current_config.json' and 'desired_config.json'. The developer plans to use the 'diff' library to perform this task. Which of the following steps are necessary to achieve this?

  1. A

    Import the 'diff' library in the script to enable comparison functionality.

  2. B

    Load the contents of the JSON files as Python dictionaries using a module like 'json'.

  3. C

    Use 'diff.diff_files()' to directly compare the two JSON files without loading their content.

  4. D

    Iterate through the differences returned by the 'diff' operation to display or log them.

  5. E

    Ensure both JSON files are converted to a common format like XML before using the 'diff' library.

Show answer and explanation

Correct answers: A, B, D

Explanation

To compare two JSON files using the 'diff' library, the developer must first import the library and load the JSON files as Python dictionaries to enable in-memory comparisons. After performing the 'diff' operation, the differences can be iterated over and displayed or logged. It is important to understand that the 'diff' library works with data structures like dictionaries rather than raw files, and there is no need to convert JSON files to other formats like XML.

  • A. Correct.

    Importing the 'diff' library is a prerequisite to using its comparison functionality in the script.

  • B. Correct.

    JSON files need to be loaded as Python dictionaries to compare their contents effectively using the 'diff' library.

  • C. Incorrect.

    'diff.diff_files()' is not a valid function in the 'diff' library; the library operates on in-memory data structures rather than files directly.

  • D. Correct.

    Iterating through the differences is necessary to process and display the results of the comparison, such as logging the differences.

  • E. Incorrect.

    Converting JSON files to XML is unnecessary and irrelevant when using the 'diff' library, as the library is designed to work with Python data structures like dictionaries.

Timed practice exam

Take a 200-901 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam