476
477 This is very cool.
478
479
481 may be translated to the following JSON name/value pair:
483 {
484 "bar": {
485 "p": "This is *very* cool."
486 }
487 }
489 3.3. Mapping YANG Datatypes to JSON Values
491 3.3.1. Numeric Datatypes
493 A value of one of the YANG numeric datatypes ("int8", "int16",
494 "int32", "int64", "uint8", "uint16", "uint32", "uint64" and
495 "decimal64") is mapped to a JSON number using the same lexical
496 representation.
498 3.3.2. The "string" Type
500 A "string" value is mapped to an identical JSON string, subject to
501 JSON encoding rules.
503 3.3.3. The "boolean" Type
505 A "boolean" value is mapped to the corresponding JSON value 'true' or
506 'false'.
508 3.3.4. The "enumeration" Type
510 An "enumeration" value is mapped in the same way as a string except
511 that the permitted values are defined by "enum" statements in YANG.
513 3.3.5. The "bits" Type
515 A "bits" value is mapped to a string identical to the lexical
516 representation of this value in XML, i.e., space-separated names
517 representing the individual bit values that are set.
519 3.3.6. The "binary" Type
521 A "binary" value is mapped to a JSON string identical to the lexical
522 representation of this value in XML, i.e., base64-encoded binary
523 data.
525 3.3.7. The "leafref" Type
527 A "leafref" value is mapped according to the same rules as the type
528 of the leaf being referred to.
530 3.3.8. The "identityref" Type
532 An "identityref" value is mapped to a string representing the
533 qualified name of the identity. Its namespace MAY be expressed as
534 shown in Figure 1. If the namespace part is not present, the
535 namespace of the name of the JSON object containing the value is
536 assumed.
538 3.3.9. The "empty" Type
540 An "empty" value is mapped to '[null]', i.e., an array with the
541 'null' value being its only element.
543 This encoding was chosen instead of using simply 'null' in order to
544 facilitate the use of empty leafs in common programming languages.
545 When used in a boolean context, the '[null]' value, unlike 'null',
546 evaluates to 'true'.
548 Example: For the leaf definition
550 leaf foo {
551 type empty;
552 }
554 the XML element
556