300-435 · Question #143
Refer to the exhibit. What is a valid JSON instance of this YANG module?
The correct answer is C. { "top": { "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] } }. This question requires creating a valid JSON instance that accurately reflects the structure and data types defined by a given YANG module.
Question
Options
- A{ "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": "2001:db8:0:1::1" } ] }
- B{ "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] }
- C{ "top": { "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] } }
- D{ "top": "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] }
How the community answered
(42 responses)- A5% (2)
- B7% (3)
- C74% (31)
- D14% (6)
Why each option
This question requires creating a valid JSON instance that accurately reflects the structure and data types defined by a given YANG module.
This option misses the encapsulating 'top' element required by the YANG module structure and contains a type mismatch for the second `seqno` (string instead of integer) if `seqno` is defined as a numerical type, plus the `ip` for the second entry is missing.
This option misses the encapsulating 'top' element, which is necessary if the YANG module defines a top-level container (e.g., `container top`) that contains the `address` list.
According to RFC 7951, which defines YANG-to-JSON mapping, if a YANG module defines a top-level container (e.g., `container top`), the JSON instance should be encapsulated within an outer object with that container's name. The JSON then correctly represents a list named `address`, where each item is an object with `seqno` (an integer) and `ip` (a string), matching the structure typically defined for a list with a key and specific leaf types.
This JSON is syntactically invalid because after `"top":`, it directly has `"address":` instead of correctly defining an object for 'top' (e.g., `{ "address": ... }`).
Concept tested: YANG to JSON mapping, JSON structure
Source: https://datatracker.ietf.org/doc/html/rfc7951
Topics
Community Discussion
No community discussion yet for this question.