nerdexam
Cisco

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.

Network Automation Foundation

Question

Refer to the exhibit. What is a valid JSON instance of this YANG module?

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)
  • A
    5% (2)
  • B
    7% (3)
  • C
    74% (31)
  • D
    14% (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.

A{ "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": "2001:db8:0:1::1" } ] }

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.

B{ "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] }

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.

C{ "top": { "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] } }Correct

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.

D{ "top": "address": [ { "seqno": 1, "ip": "192.0.2.1" }, { "seqno": 2, "ip": "2001:db8:0:1::1" } ] }

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

#YANG#JSON#Data Modeling#RESTCONF

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice