CCNA 200-301 · Automation and Programmability · easy

Examine the following JSON payload returned by a Cisco IOS XE RESTCONF query: json { "ietf-interfaces:interface": { "name": "GigabitEthernet1", "enabled": true, "ipv4": { "address": [ { "ip": "10.1.1.1", "netmask": "255.255.255.0" } ] } } } In JSON syntax, what data types are represented by the values of "enabled" (true) and "address" ([ { ... } ])?

Published · Last updated · checked before publication — how we verify questions

Options

  • A"enabled" is a String and "address" is a floating-point Number
  • B"enabled" is a Boolean and "address" is an Array of ObjectsCorrect answer
  • C"enabled" is an Array and "address" is a null pointer reference
  • DBoth "enabled" and "address" are XML CDATA string attributes

Answer: B. "enabled" is a Boolean and "address" is an Array of Objects

The keyed answer is correct. In JSON, the literals true and false (written without quotes, in lowercase) are the Boolean type, so the value of "enabled" is a Boolean. The value of "address" begins with a square bracket, which marks a JSON array, an ordered list of values. Each element of this array is itself enclosed in curly braces, which marks a JSON object made of key-value pairs, here "ip" and "netmask". So "address" is an array of objects. This is the usual shape of YANG list data in RESTCONF, where a list of entries such as multiple IP addresses on one interface is encoded as an array. The most common trap is confusing quoting and brackets: a quoted value would be a string, while true without quotes is a Boolean. Another is treating the square brackets and the curly braces as interchangeable, when [] means array and {} means object.

Why the other options are wrong

  • A. "enabled" is a String and "address" is a floating-point Number — This option says "enabled" is a String, but a string must be enclosed in double quotes, and true is unquoted, so it is a Boolean. It also calls "address" a floating-point Number, but a Number is a bare numeric literal such as 3.14, never a bracketed list.
  • C. "enabled" is an Array and "address" is a null pointer reference — This option says "enabled" is an Array, but an array needs square brackets and "enabled" holds a bare true. It also says "address" is null, but null is a separate literal written as null, and "address" holds a populated list. The array is actually on "address", not "enabled", so the types are swapped and wrong.
  • D. Both "enabled" and "address" are XML CDATA string attributes — CDATA sections and attributes are XML constructs and do not exist in JSON. This payload uses JSON syntax with braces, brackets, and colon-separated key-value pairs. RESTCONF can return XML as well as JSON, but the question asks about JSON data types, so XML terms do not apply.

All Automation and Programmability questions and the topic overview →

Cisco and CCNA are trademarks of Cisco Systems, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Cisco Systems, Inc.