200-301 Question 503
Select 3You are troubleshooting an API call that returns the following JSON data:
{ "device": { "hostname": "Router1", "interfaces": [ { "name": "GigabitEthernet0/1", "status": "up" }, { "name": "GigabitEthernet0/2", "status": "down" } ] } }
Which of the following statements correctly identifies components of this JSON-encoded data?
- A
"device" is a JSON object.
- B
"interfaces" is a JSON array.
- C
"status" is a JSON object.
- D
"hostname" is a JSON key with a string value.
- E
"name" is a JSON array.
Show answer and explanation
Correct answers: A, B, D
Explanation
JSON data is structured with key-value pairs, objects (enclosed in curly braces), arrays (enclosed in square brackets), and primitive values like strings, numbers, and booleans. In this scenario, "device" is a JSON object containing nested data, "interfaces" is a JSON array containing multiple objects, and "hostname" is a JSON key with a string value. Understanding how to identify these components is crucial for interpreting JSON data in network automation and API interactions.
- A. Correct.
Correct: The key "device" contains a set of key-value pairs enclosed within curly braces, making it a JSON object.
- B. Correct.
Correct: The key "interfaces" contains multiple objects enclosed in square brackets, making it a JSON array.
- C. Incorrect.
Incorrect: The key "status" contains a string value ("up" or "down"), not a set of key-value pairs, so it is not a JSON object.
- D. Correct.
Correct: The key "hostname" contains a single string value ("Router1"), making it a JSON key with a string value.
- E. Incorrect.
Incorrect: The key "name" contains a string value (e.g., "GigabitEthernet0/1"), not an array, so it is not a JSON array.