A developer models a switch interface with YANG where config holds a container interfaces, a list interface keyed by name, and leaf enabled. The REST payload must mirror that hierarchy exactly. Which JSON instance correctly maps the YANG leaf, container and list to JSON structure?
Select an answer to reveal the explanation.
Short Explanation
You’re matching each JSON level to the YANG model: the container is an object, and the list is an array of objects with the name key and enabled leaf. Your hierarchy stays intact when you keep the container, list entries, and leaf in their modeled places.
Full Explanation
The JSON instance that mirrors the YANG hierarchy uses an object for the interfaces container, an array for its interface list, and an object for each list entry containing both the name key and enabled leaf. Representing the list as an object keyed by interface name may seem convenient for lookup, but it changes the list’s JSON structure from an array to an object. Using an array of entry objects but omitting enabled preserves the container and list shapes, yet fails to represent the stated leaf in the instance. Flattening interfaces into the root while retaining an array with name and enabled preserves the list entries, but removes the container level, so the payload no longer mirrors the hierarchy exactly. Exam caveat: distinguish the abstract YANG data tree from the encoding rules of a particular protocol; JSON conventions or custom APIs may differ, but this question explicitly requires the JSON structure to mirror the model. Practical check: compare each nesting level in the payload with the schema, then confirm that list entries are represented as array elements and include the key and required leaf.