nerdexam
Cisco

200-901 · Question #159

Refer to the exhibit. The JSON data in the exhibit has been parsed and stored into a variable "data". What returns the value "172.16.0.11"?

The correct answer is A. data['items'][0]['host']['value']. The correct answer is A: data['items'][0]['host']['value']. In the exhibit, 'items' is a JSON array (indicated by square brackets), so elements are accessed by zero-based integer index. The first element is at index 0 (not 1, and not a string key). Within that element, 'host' is

Understanding and Using APIs

Question

Refer to the exhibit. The JSON data in the exhibit has been parsed and stored into a variable "data". What returns the value "172.16.0.11"?

Exhibit

200-901 question #159 exhibit

Options

  • Adata['items'][0]['host']['value']
  • Bdata['items']['1']['host']['value']
  • Cdata['items']['host'][1]
  • Ddata['items']['host']['value']

How the community answered

(19 responses)
  • A
    79% (15)
  • B
    11% (2)
  • C
    5% (1)
  • D
    5% (1)

Explanation

The correct answer is A: data['items'][0]['host']['value']. In the exhibit, 'items' is a JSON array (indicated by square brackets), so elements are accessed by zero-based integer index. The first element is at index 0 (not 1, and not a string key). Within that element, 'host' is an object with a 'value' key holding the IP address. Answer B is incorrect because '1' (a string) is used as the index instead of the integer 0; array indices must be integers. Answer C is incorrect because it skips the 'value' key and treats 'host' as an array. Answer D is incorrect because it omits the array index entirely, treating 'items' as a dictionary instead of a list.

Topics

#JSON Parsing#Data Structures#API Data Access#Python Indexing

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice