nerdexam
Cisco

300-435 · Question #71

A web service returns a JSON object to your Python script. What is the most logical object in which to store the JSON response?

The correct answer is B. a dictionary. The most logical Python object to store a JSON response from a web service is a dictionary, as JSON objects directly map to Python dictionaries.

Network Automation Foundation

Question

A web service returns a JSON object to your Python script. What is the most logical object in which to store the JSON response?

Options

  • Aan integer
  • Ba dictionary
  • Ca tuple
  • Da string
  • Ea list

How the community answered

(39 responses)
  • B
    95% (37)
  • C
    3% (1)
  • E
    3% (1)

Why each option

The most logical Python object to store a JSON response from a web service is a dictionary, as JSON objects directly map to Python dictionaries.

Aan integer

An integer can only hold a single numerical value, which is insufficient for a structured JSON object.

Ba dictionaryCorrect

When a web service returns a JSON object, the Python `json` module, or methods like `response.json()` from the `requests` library, will parse it into a Python dictionary. This is because JSON objects are composed of key-value pairs, which directly correspond to the structure of a Python dictionary.

Ca tuple

A tuple is an immutable ordered sequence and does not naturally represent the key-value structure of a JSON object.

Da string

A string can hold the raw JSON text, but it must be parsed to become an accessible Python data structure, making it less logical for direct storage and manipulation.

Ea list

A list is an ordered sequence of items, whereas a JSON object is an unordered collection of key-value pairs, which is better represented by a dictionary.

Concept tested: JSON to Python data type mapping

Source: https://docs.python.org/3/library/json.html

Topics

#JSON#Python Data Structures#API Interaction

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice