The correct answer is D. print(json_object[ " TABLE_intf " ][ " ROW_intf " ][0] [ " prefix " ]).
Parsing JSON output from Cisco devices
Using Python to extract structured data
Understanding how CLI output is converted into JSON format
show ip int brief | json
returns structured JSON data.
{
" TABLE_intf " : {
" ROW_intf " : [
{ " intf-name " : " Vlan100 " , " prefix " : " 192.168.10.1 " , ... },
{ " intf-name " : " Vlan200 " , " prefix " : " 192.168.20.1 " , ... },
...
]
}
}
Important Observations:
ROW_intf is a list (array) of interface objects.
Each object contains fields like " prefix " (IP address).
VLAN 100 is used for management and appears first in the list.
Python Code Analysis:
json_object[ " TABLE_intf " ][ " ROW_intf " ][0] [ " prefix " ]
Why Option D is Correct:
Uses the correct variable ( json_object )
Correctly navigates dictionary → list → element → key
Index [0] corresponds to Vlan100 (management VLAN)
A & B: Use json.dumps incorrectly (this function converts Python → JSON, not for accessing data)
C: Uses index [1] , which refers to Vlan200, not VLAN100
When working with Cisco JSON output:
Identify list vs dictionary
Use indexing for lists ( [0] )
Use keys for dictionaries ( [ " key " ] )
Correct Pattern:
json_object[ " parent " ][ " child " ][index] [ " field " ]