Question

Difficulty: EasyInterpreting JSON Encoded Data

A network technician uses a REST API call to retrieve VLAN configuration data from a Cisco switch. The device returns the following JSON payload:

{
"response": {
"vlan_list": [
{
"vlan_id": 10,
"name": "Management",
"active": true
},
{
"vlan_id": 20,
"name": "Engineering",
"active": false
}
],
"total_vlans": 2
}
}

Based on this JSON payload, which of the following statements are correct? (Select TWO.)

  1. The key "vlan_list" contains an array of JSON objects enclosed in square brackets.Answer
  2. The value for the key "active" in the "Engineering" VLAN object is an unquoted boolean data type.Answer
  3. C
    The key "total_vlans" holds a string data type value.
  4. D
    The key "vlan_list" directly maps to a single dictionary object enclosed in curly braces.

Answer

The key "vlan_list" contains an array of JSON objects, and the value for "active" in the Engineering VLAN is a boolean data type.
The payload uses square brackets `[]` under `vlan_list` to represent an array of objects. Additionally, the value `false` assigned to `active` is unquoted, which correctly identifies it as a native JSON boolean data type.

Step-by-Step Solution

1
Inspect the syntax following the key "vlan_list".
The value starts with square brackets `[ ... ]`, which defines a JSON array containing two curly-brace `{ ... }` dictionary objects.
Square brackets signify arrays in JSON, whereas curly braces denote standalone key-value objects.
2
Analyze the data type assigned to the key "active" inside the second array item.
The second object has `"name": "Engineering"` and `"active": false` without quotation marks around `false`.
Unquoted `true` or `false` values represent boolean data types in JSON syntax.
3
Evaluate the remaining keys and data types.
`"total_vlans": 2` contains an unquoted numerical value (integer), not a string.
String values in JSON must always be wrapped in double quotes (e.g., `"2"`).

Key Concept

Interpreting JSON syntax elements including arrays, objects, strings, numbers, and boolean data types.
Rate this question