idnits 2.17.1 draft-ietf-netmod-yang-json-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 07, 2015) is 3117 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '123' on line 335 -- Looks like a reference, but probably isn't: '0' on line 335 == Outdated reference: A later version (-14) exists of draft-ietf-netmod-rfc6020bis-07 ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) == Outdated reference: A later version (-18) exists of draft-ietf-netconf-restconf-07 -- Obsolete informational reference (is this intentional?): RFC 7223 (Obsoleted by RFC 8343) Summary: 2 errors (**), 0 flaws (~~), 3 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 NETMOD Working Group L. Lhotka 3 Internet-Draft CZ.NIC 4 Intended status: Standards Track October 07, 2015 5 Expires: April 9, 2016 7 JSON Encoding of Data Modeled with YANG 8 draft-ietf-netmod-yang-json-06 10 Abstract 12 This document defines encoding rules for representing configuration, 13 state data, RPC operation or action input and output parameters, and 14 notifications defined using YANG as JavaScript Object Notation (JSON) 15 text. 17 Status of This Memo 19 This Internet-Draft is submitted in full conformance with the 20 provisions of BCP 78 and BCP 79. 22 Internet-Drafts are working documents of the Internet Engineering 23 Task Force (IETF). Note that other groups may also distribute 24 working documents as Internet-Drafts. The list of current Internet- 25 Drafts is at http://datatracker.ietf.org/drafts/current/. 27 Internet-Drafts are draft documents valid for a maximum of six months 28 and may be updated, replaced, or obsoleted by other documents at any 29 time. It is inappropriate to use Internet-Drafts as reference 30 material or to cite them other than as "work in progress." 32 This Internet-Draft will expire on April 9, 2016. 34 Copyright Notice 36 Copyright (c) 2015 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents 41 (http://trustee.ietf.org/license-info) in effect on the date of 42 publication of this document. Please review these documents 43 carefully, as they describe your rights and restrictions with respect 44 to this document. Code Components extracted from this document must 45 include Simplified BSD License text as described in Section 4.e of 46 the Trust Legal Provisions and are provided without warranty as 47 described in the Simplified BSD License. 49 Table of Contents 51 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 52 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 53 3. Properties of the JSON Encoding . . . . . . . . . . . . . . . 4 54 4. Names and Namespaces . . . . . . . . . . . . . . . . . . . . 4 55 5. Encoding of YANG Data Node Instances . . . . . . . . . . . . 6 56 5.1. The "leaf" Data Node . . . . . . . . . . . . . . . . . . 7 57 5.2. The "container" Data Node . . . . . . . . . . . . . . . . 7 58 5.3. The "leaf-list" Data Node . . . . . . . . . . . . . . . . 7 59 5.4. The "list" Data Node . . . . . . . . . . . . . . . . . . 8 60 5.5. The "anydata" Data Node . . . . . . . . . . . . . . . . . 9 61 5.6. The "anyxml" Data Node . . . . . . . . . . . . . . . . . 10 62 6. Representing YANG Data Types in JSON Values . . . . . . . . . 10 63 6.1. Numeric Types . . . . . . . . . . . . . . . . . . . . . . 10 64 6.2. The "string" Type . . . . . . . . . . . . . . . . . . . . 11 65 6.3. The "boolean" Type . . . . . . . . . . . . . . . . . . . 11 66 6.4. The "enumeration" Type . . . . . . . . . . . . . . . . . 11 67 6.5. The "bits" Type . . . . . . . . . . . . . . . . . . . . . 11 68 6.6. The "binary" Type . . . . . . . . . . . . . . . . . . . . 11 69 6.7. The "leafref" Type . . . . . . . . . . . . . . . . . . . 12 70 6.8. The "identityref" Type . . . . . . . . . . . . . . . . . 12 71 6.9. The "empty" Type . . . . . . . . . . . . . . . . . . . . 12 72 6.10. The "union" Type . . . . . . . . . . . . . . . . . . . . 13 73 6.11. The "instance-identifier" Type . . . . . . . . . . . . . 14 74 7. I-JSON Compliance . . . . . . . . . . . . . . . . . . . . . . 14 75 8. Security Considerations . . . . . . . . . . . . . . . . . . . 15 76 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 15 77 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 78 10.1. Normative References . . . . . . . . . . . . . . . . . . 15 79 10.2. Informative References . . . . . . . . . . . . . . . . . 16 80 Appendix A. A Complete Example . . . . . . . . . . . . . . . . . 16 81 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 18 82 B.1. Changes Between Revisions -05 and -06 . . . . . . . . . . 18 83 B.2. Changes Between Revisions -04 and -05 . . . . . . . . . . 18 84 B.3. Changes Between Revisions -03 and -04 . . . . . . . . . . 19 85 B.4. Changes Between Revisions -02 and -03 . . . . . . . . . . 19 86 B.5. Changes Between Revisions -01 and -02 . . . . . . . . . . 19 87 B.6. Changes Between Revisions -00 and -01 . . . . . . . . . . 19 88 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 20 90 1. Introduction 92 The NETCONF protocol [RFC6241] uses XML [W3C.REC-xml-20081126] for 93 encoding data in its Content Layer. Other management protocols might 94 want to use other encodings while still benefiting from using YANG 95 [I-D.ietf-netmod-rfc6020bis] as the data modeling language. 97 For example, the RESTCONF protocol [I-D.ietf-netconf-restconf] 98 supports two encodings: XML (media type "application/yang.data+xml") 99 and JSON (media type "application/yang.data+json"). 101 The specification of YANG 1.1 data modelling language 102 [I-D.ietf-netmod-rfc6020bis] defines only XML encoding for data 103 instances, i.e., contents of configuration datastores, state data, 104 RPC operation or action input and output parameters, and event 105 notifications. The aim of this document is to define rules for 106 encoding the same data as JavaScript Object Notation (JSON) 107 text [RFC7159]. 109 2. Terminology and Notation 111 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 112 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 113 document are to be interpreted as described in [RFC2119]. 115 The following terms are defined in [I-D.ietf-netmod-rfc6020bis]: 117 o action, 119 o anydata, 121 o anyxml, 123 o augment, 125 o container, 127 o data node, 129 o data tree, 131 o identity, 133 o instance identifier, 135 o leaf, 137 o leaf-list, 139 o list, 141 o module, 143 o RPC operation, 144 o submodule. 146 3. Properties of the JSON Encoding 148 This document defines JSON encoding for YANG data trees and their 149 subtrees. It is always assumed that the top-level structure in JSON- 150 encoded data is an object. 152 Instances of YANG data nodes (leafs, containers, leaf-lists, lists, 153 anydata and anyxml nodes) are encoded as members of a JSON object, 154 i.e., name/value pairs. Section 4 defines how the name part is 155 formed, and the following sections deal with the value part. 157 Unlike XML element content, JSON values carry partial type 158 information (number, string, boolean). The JSON encoding is defined 159 so that this information is never in conflict with the data type of 160 the corresponding YANG leaf or leaf-list. 162 With the exception of anyxml and schema-less anydata nodes, it is 163 possible to map a JSON-encoded data tree to XML encoding as defined 164 in [I-D.ietf-netmod-rfc6020bis], and vice versa. However, such 165 conversions require the YANG data model to be available. 167 In order to achieve maximum interoperability while allowing 168 implementations to use a variety of existing JSON parsers, the JSON 169 encoding rules follow, as much as possible, the constraints of the 170 I-JSON restricted profile [RFC7493]. Section 7 discusses I-JSON 171 conformance in more detail. 173 4. Names and Namespaces 175 An object member name MUST be in one of the following forms: 177 o simple - identical to the identifier of the corresponding YANG 178 data node; 180 o namespace-qualified - the data node identifier is prefixed with 181 the name of the module in which the data node is defined, 182 separated from the data node identifier by the colon character 183 (":"). 185 The name of a module determines the namespace of all data node names 186 defined in that module. If a data node is defined in a submodule, 187 then the namespace-qualified member name uses the name of the main 188 module to which the submodule belongs. 190 ABNF syntax [RFC5234] of a member name is shown in Figure 1, where 191 the production for "identifier" is defined in sec. 13 of 192 [I-D.ietf-netmod-rfc6020bis]. 194 member-name = [identifier ":"] identifier 196 Figure 1: ABNF production for a JSON member name. 198 A namespace-qualified member name MUST be used for all members of a 199 top-level JSON object, and then also whenever the namespaces of the 200 data node and its parent node are different. In all other cases, the 201 simple form of the member name MUST be used. 203 For example, consider the following YANG module: 205 module foomod { 207 namespace "http://example.com/foomod"; 209 prefix "foo"; 211 container top { 212 leaf foo { 213 type uint8; 214 } 215 } 216 } 218 If the data model consists only of this module, then the following is 219 a valid JSON-encoded configuration: 221 { 222 "foomod:top": { 223 "foo": 54 224 } 225 } 227 Note that the member of the top-level object uses the namespace- 228 qualified name but the "foo" leaf doesn't because it is defined in 229 the same module as its parent container "top". 231 Now, assume the container "top" is augmented from another module, 232 "barmod": 234 module barmod { 236 namespace "http://example.com/barmod"; 238 prefix "bar"; 240 import foomod { 241 prefix "foo"; 242 } 244 augment "/foo:top" { 245 leaf bar { 246 type boolean; 247 } 248 } 249 } 251 A valid JSON-encoded configuration containing both leafs may then 252 look like this: 254 { 255 "foomod:top": { 256 "foo": 54, 257 "barmod:bar": true 258 } 259 } 261 The name of the "bar" leaf is prefixed with the namespace identifier 262 because its parent is defined in a different module. 264 Explicit namespace identifiers are sometimes needed when encoding 265 values of the "identityref" and "instances-identifier" types. The 266 same form of namespace-qualified name as defined above is then used. 267 See Sections 6.8 and 6.11 for details. 269 5. Encoding of YANG Data Node Instances 271 Every data node instance is encoded as a name/value pair where the 272 name is formed from the data node identifier using the rules of 273 Section 4. The value depends on the category of the data node as 274 explained in the following subsections. 276 Character encoding MUST be UTF-8. 278 5.1. The "leaf" Data Node 280 A leaf instance is encoded as a name/value pair where the value can 281 be a string, number, literal "true" or "false", or the special array 282 "[null]", depending on the type of the leaf (see Section 6 for the 283 type encoding rules). 285 Example: For the leaf node definition 287 leaf foo { 288 type uint8; 289 } 291 the following is a valid JSON-encoded instance: 293 "foo": 123 295 5.2. The "container" Data Node 297 A container instance is encoded as a name/object pair. The 298 container's child data nodes are encoded as members of the object. 300 Example: For the container definition 302 container bar { 303 leaf foo { 304 type uint8; 305 } 306 } 308 the following is a valid JSON-encoded instance: 310 "bar": { 311 "foo": 123 312 } 314 5.3. The "leaf-list" Data Node 316 A leaf-list is encoded as a name/array pair, and the array elements 317 are values of some scalar type, which can be a string, number, 318 literal "true" or "false", or the special array "[null]", depending 319 on the type of the leaf-list (see Section 6 for the type encoding 320 rules). 322 The ordering of array elements follows the same rules as the ordering 323 of XML elements representing leaf-list entries in the XML encoding. 324 Specifically, the "ordered-by" properties (sec. 7.7.7 in 325 [I-D.ietf-netmod-rfc6020bis]) MUST be observed. 327 Example: For the leaf-list definition 329 leaf-list foo { 330 type uint8; 331 } 333 the following is a valid JSON-encoded instance: 335 "foo": [123, 0] 337 5.4. The "list" Data Node 339 A list instance is encoded as a name/array pair, and the array 340 elements are JSON objects. 342 The ordering of array elements follows the same rules as the ordering 343 of XML elements representing list entries in the XML encoding. 344 Specifically, the "ordered-by" properties (sec. 7.7.7 in 345 [I-D.ietf-netmod-rfc6020bis]) MUST be observed. 347 Unlike the XML encoding, where list keys are required to precede any 348 other siblings within a list entry, and appear in the order specified 349 by the data model, the order of members in a JSON-encoded list entry 350 is arbitrary because JSON objects are fundamentally unordered 351 collections of members. 353 Example: For the list definition 355 list bar { 356 key foo; 357 leaf foo { 358 type uint8; 359 } 360 leaf baz { 361 type string; 362 } 363 } 365 the following is a valid JSON-encoded instance: 367 "bar": [ 368 { 369 "foo": 123, 370 "baz": "zig" 371 }, 372 { 373 "baz": "zag", 374 "foo": 0 375 } 376 ] 378 5.5. The "anydata" Data Node 380 Anydata data node serves as a container for an arbitrary set of nodes 381 that otherwise appear as normal YANG-modeled data. A data model for 382 anydata content may or may not be known at run time. In the latter 383 case, converting JSON-encoded instances to the XML encoding defined 384 in [I-D.ietf-netmod-rfc6020bis] may be impossible. 386 An anydata instance is encoded in the same way as a container, i.e., 387 as a value/object pair. The requirement that anydata content can be 388 modeled by YANG implies the following rules for the JSON text inside 389 the object: 391 o It is valid I-JSON [RFC7493]. 393 o All object member names satisfy the ABNF production in Figure 1. 395 o Any JSON array contains either only unique scalar values (as a 396 leaf-list, see Section 5.3), or only objects (as a list, see 397 Section 5.4). 399 o The "null" value is only allowed in the single-element array 400 "[null]" corresponding to the encoding of the "empty" type, see 401 Section 6.9. 403 Example: for the anydata definition 405 anydata data; 407 the following is a valid JSON-encoded instance: 409 "data": { 410 "ietf-notification:notification": { 411 "eventTime": "2014-07-29T13:43:01Z", 412 "example-event:event": { 413 "event-class": "fault", 414 "reporting-entity": { 415 "card": "Ethernet0" 416 }, 417 "severity": "major" 418 } 419 } 420 } 422 5.6. The "anyxml" Data Node 424 An anyxml instance is encoded as a JSON name/value pair which MUST 425 satisfy I-JSON constraints. Otherwise it is unrestricted, i.e., the 426 value can be an object, array, number, string or one of the literals 427 "true", "false" and "null". 429 There is no universal procedure for mapping JSON-encoded anyxml 430 instances to XML, and vice versa. 432 Example: For the anyxml definition 434 anyxml bar; 436 the following is a valid JSON-encoded instance: 438 "bar": [true, null, true] 440 6. Representing YANG Data Types in JSON Values 442 The type of the JSON value in an instance of the leaf or leaf-list 443 data node depends on the type of that data node as specified in the 444 following subsections. 446 6.1. Numeric Types 448 A value of the types "int8", "int16", "int32", "uint8", "uint16" and 449 "uint32" is represented as a JSON number. 451 A value of the "int64", "uint64" or "decimal64" type is represented 452 as a JSON string whose content is the lexical representation of the 453 corresponding YANG type as specified in sections 9.2.1 and 9.3.1 of 454 [I-D.ietf-netmod-rfc6020bis]. 456 For example, if the type of the leaf "foo" in Section 5.1 was 457 "uint64" instead of "uint8", the instance would have to be encoded as 459 "foo": "123" 461 The special handling of 64-bit numbers follows from the I-JSON 462 recommendation to encode numbers exceeding the IEEE 754-2008 double 463 precision range as strings, see sec. 2.2 in [RFC7493]. 465 6.2. The "string" Type 467 A "string" value is represented as a JSON string, subject to JSON 468 string encoding rules. 470 6.3. The "boolean" Type 472 A "boolean" value is represented as the corresponding JSON literal 473 name "true" or "false". 475 6.4. The "enumeration" Type 477 An "enumeration" value is represented as a JSON string - one of the 478 names assigned by "enum" statements in YANG. 480 The representation is identical to the lexical representation of the 481 "enumeration" type in XML, see sec. 9.6 in 482 [I-D.ietf-netmod-rfc6020bis]. 484 6.5. The "bits" Type 486 A "bits" value is represented as a JSON string - a space-separated 487 sequence of names of bits that are set. The permitted bit names are 488 assigned by "bit" statements in YANG. 490 The representation is identical to the lexical representation of the 491 "bits" type, see sec. 9.7 in [I-D.ietf-netmod-rfc6020bis]. 493 6.6. The "binary" Type 495 A "binary" value is represented as a JSON string - base64-encoding of 496 arbitrary binary data. 498 The representation is identical to the lexical representation of the 499 "binary" type in XML, see sec. 9.8 in [I-D.ietf-netmod-rfc6020bis]. 501 6.7. The "leafref" Type 503 A "leafref" value is represented using the same rules as the type of 504 the leaf to which the leafref value refers. 506 6.8. The "identityref" Type 508 An "identityref" value is represented as a string - the name of an 509 identity. If the identity is defined in another module than the leaf 510 node containing the identityref value, the namespace-qualified form 511 (Section 4) MUST be used. Otherwise, both the simple and namespace- 512 qualified forms are permitted. 514 For example, consider the following schematic module: 516 module exmod { 517 ... 518 import ietf-interfaces { 519 prefix if; 520 } 521 import iana-if-type { 522 prefix ianaift; 523 } 524 ... 525 leaf type { 526 type identityref { 527 base "if:interface-type"; 528 } 529 } 530 } 532 A valid instance of the "type" leaf is then encoded as follows: 534 "type": "iana-if-type:ethernetCsmacd" 536 The namespace identifier "iana-if-type" must be present in this case 537 because the "ethernetCsmacd" identity is not defined in the same 538 module as the "type" leaf. 540 6.9. The "empty" Type 542 An "empty" value is represented as "[null]", i.e., an array with the 543 "null" literal being its only element. For the purposes of this 544 document, "[null]" is considered an atomic scalar value. 546 This encoding of the "empty" type was chosen instead of using simply 547 "null" in order to facilitate the use of empty leafs in common 548 programming languages where the "null" value of a member is treated 549 as if the member is not present. 551 Example: For the leaf definition 553 leaf foo { 554 type empty; 555 } 557 a valid instance is 559 "foo": [null] 561 6.10. The "union" Type 563 A value of the "union" type is encoded as the value of any of the 564 member types. 566 When validating a value of the "union" type, the type information 567 conveyed by the JSON encoding MUST also be taken into account. JSON 568 syntax thus provides additional means for resolving union member type 569 that are not available in XML encoding. 571 For example, consider the following YANG definition: 573 leaf bar { 574 type union { 575 type uint16; 576 type string; 577 } 578 } 580 In RESTCONF [I-D.ietf-netconf-restconf], it is possible to set the 581 value of "bar" in the following way when using the "application/ 582 yang.data+xml" media type: 584 13.5 586 because the value may be interpreted as a string, i.e., the second 587 member type of the union. When using the "application/ 588 yang.data+json" media type, however, this is an error: 590 "bar": 13.5 592 In this case, the JSON encoding indicates the value is supposed to be 593 a number rather than a string, and it is not a valid "uint16" value. 595 Conversely, the value of 596 "bar": "1" 598 is to be interpreted as a string. 600 6.11. The "instance-identifier" Type 602 An "instance-identifier" value is encoded as a string that is 603 analogical to the lexical representation in XML encoding, see 604 sec. 9.13.3 in [I-D.ietf-netmod-rfc6020bis]. However, the encoding 605 of namespaces in instance-identifier values follows the rules stated 606 in Section 4, namely: 608 o The leftmost (top-level) data node name is always in the 609 namespace-qualified form. 611 o Any subsequent data node name is in the namespace-qualified form 612 if the node is defined in another module than its parent node, and 613 the simple form is used otherwise. This rule also holds for node 614 names appearing in predicates. 616 For example, 618 /ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/ip 620 is a valid instance-identifer value because the data nodes 621 "interfaces", "interface" and "name" are defined in the module "ietf- 622 interfaces", whereas "ipv4" and "ip" are defined in "ietf-ip". 624 7. I-JSON Compliance 626 I-JSON [RFC7493] is a restricted profile of JSON that guarantees 627 maximum interoperability for protocols that use JSON in their 628 messages, no matter what JSON encoders/decoders are used in protocol 629 implementations. The encoding defined in this document therefore 630 observes the I-JSON requirements and recommendations as closely as 631 possible. 633 In particular, the following properties are guaranteed: 635 o Character encoding is UTF-8. 637 o Member names within the same JSON object are always unique. 639 o The order of JSON object members is never relied upon. 641 o Numbers of any type supported by YANG can be exchanged reliably. 642 See Section 6.1 for details. 644 The JSON encoding defined in this document deviates from I-JSON only 645 in the representation of the "binary" type. In order to remain 646 compatible with XML encoding, the base64 encoding scheme is used 647 (Section 6.6), whilst I-JSON recommends base64url instead. 649 8. Security Considerations 651 This document defines an alternative encoding for data modeled in the 652 YANG data modeling language. As such, it doesn't contribute any new 653 security issues beyond those discussed in sec. 16 of 654 [I-D.ietf-netmod-rfc6020bis]. 656 JSON processing is rather different from XML, and JSON parsers may 657 thus suffer from other types of vulnerabilities than their XML 658 counterparts. To minimize these new security risks, software on the 659 receiving side SHOULD reject all messages that do not comply to the 660 rules of this document and reply with an appropriate error message to 661 the sender. 663 9. Acknowledgments 665 The author wishes to thank Andy Bierman, Martin Bjorklund, Dean 666 Bogdanovic, Balazs Lengyel, Juergen Schoenwaelder and Phil Shafer for 667 their helpful comments and suggestions. 669 10. References 671 10.1. Normative References 673 [I-D.ietf-netmod-rfc6020bis] 674 Bjorklund, M., "The YANG 1.1 Data Modeling Language", 675 draft-ietf-netmod-rfc6020bis-07 (work in progress), 676 September 2015. 678 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 679 Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ 680 RFC2119, March 1997, 681 . 683 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 684 Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/ 685 RFC5234, January 2008, 686 . 688 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 689 and A. Bierman, Ed., "Network Configuration Protocol 690 (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, 691 . 693 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 694 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 695 2014, . 697 [RFC7493] Bray, T., Ed., "The I-JSON Message Format", RFC 7493, DOI 698 10.17487/RFC7493, March 2015, 699 . 701 10.2. Informative References 703 [I-D.ietf-netconf-restconf] 704 Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF 705 Protocol", draft-ietf-netconf-restconf-07 (work in 706 progress), July 2015. 708 [RFC7223] Bjorklund, M., "A YANG Data Model for Interface 709 Management", RFC 7223, DOI 10.17487/RFC7223, May 2014, 710 . 712 [W3C.REC-xml-20081126] 713 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 714 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 715 Edition)", World Wide Web Consortium Recommendation REC- 716 xml-20081126, November 2008, 717 . 719 Appendix A. A Complete Example 721 The JSON document shown below represents the same data as the reply 722 to the NETCONF request appearing in Appendix D of [RFC7223]. 723 The data model is a combination of two YANG modules: "ietf- 724 interfaces" and "ex-vlan" (the latter is an example module from 725 Appendix C of [RFC7223]). The "if-mib" feature defined in the "ietf- 726 interfaces" module is considered to be active. 728 { 729 "ietf-interfaces:interfaces": { 730 "interface": [ 731 { 732 "name": "eth0", 733 "type": "iana-if-type:ethernetCsmacd", 734 "enabled": false 735 }, 736 { 737 "name": "eth1", 738 "type": "iana-if-type:ethernetCsmacd", 739 "enabled": true, 740 "ex-vlan:vlan-tagging": true 742 }, 743 { 744 "name": "eth1.10", 745 "type": "iana-if-type:l2vlan", 746 "enabled": true, 747 "ex-vlan:base-interface": "eth1", 748 "ex-vlan:vlan-id": 10 749 }, 750 { 751 "name": "lo1", 752 "type": "iana-if-type:softwareLoopback", 753 "enabled": true 754 } 755 ] 756 }, 757 "ietf-interfaces:interfaces-state": { 758 "interface": [ 759 { 760 "name": "eth0", 761 "type": "iana-if-type:ethernetCsmacd", 762 "admin-status": "down", 763 "oper-status": "down", 764 "if-index": 2, 765 "phys-address": "00:01:02:03:04:05", 766 "statistics": { 767 "discontinuity-time": "2013-04-01T03:00:00+00:00" 768 } 769 }, 770 { 771 "name": "eth1", 772 "type": "iana-if-type:ethernetCsmacd", 773 "admin-status": "up", 774 "oper-status": "up", 775 "if-index": 7, 776 "phys-address": "00:01:02:03:04:06", 777 "higher-layer-if": [ 778 "eth1.10" 779 ], 780 "statistics": { 781 "discontinuity-time": "2013-04-01T03:00:00+00:00" 782 } 783 }, 784 { 785 "name": "eth1.10", 786 "type": "iana-if-type:l2vlan", 787 "admin-status": "up", 788 "oper-status": "up", 789 "if-index": 9, 790 "lower-layer-if": [ 791 "eth1" 792 ], 793 "statistics": { 794 "discontinuity-time": "2013-04-01T03:00:00+00:00" 795 } 796 }, 797 { 798 "name": "eth2", 799 "type": "iana-if-type:ethernetCsmacd", 800 "admin-status": "down", 801 "oper-status": "down", 802 "if-index": 8, 803 "phys-address": "00:01:02:03:04:07", 804 "statistics": { 805 "discontinuity-time": "2013-04-01T03:00:00+00:00" 806 } 807 }, 808 { 809 "name": "lo1", 810 "type": "iana-if-type:softwareLoopback", 811 "admin-status": "up", 812 "oper-status": "up", 813 "if-index": 1, 814 "statistics": { 815 "discontinuity-time": "2013-04-01T03:00:00+00:00" 816 } 817 } 818 ] 819 } 820 } 822 Appendix B. Change Log 824 RFC Editor: Remove this section upon publication as an RFC. 826 B.1. Changes Between Revisions -05 and -06 828 o More text and a new example about resolving union-type values. 830 B.2. Changes Between Revisions -04 and -05 832 o Removed section "Validation of JSON-encoded Instance Data" and 833 other text about XML-JSON mapping. 835 o Added section "Properties of the JSON Encoding". 837 B.3. Changes Between Revisions -03 and -04 839 o I-D.ietf-netmod-rfc6020bis is used as a normative reference 840 instead of RFC 6020. 842 o Removed noncharacters as an I-JSON issue because it doesn't exist 843 in YANG 1.1. 845 o Section about anydata encoding was added. 847 o Require I-JSON for anyxml encoding. 849 o Use ABNF for defining qualified name. 851 B.4. Changes Between Revisions -02 and -03 853 o Namespace encoding is defined without using RFC 2119 keywords. 855 o Specification for anyxml nodes was extended and clarified. 857 o Text about ordering of list entries was corrected. 859 B.5. Changes Between Revisions -01 and -02 861 o Encoding of namespaces in instance-identifiers was changed. 863 o Text specifying the order of array elements in leaf-list and list 864 instances was added. 866 B.6. Changes Between Revisions -00 and -01 868 o Metadata encoding was moved to a separate I-D, draft-lhotka- 869 netmod-yang-metadata. 871 o JSON encoding is now defined directly rather than via XML-JSON 872 mapping. 874 o The rules for namespace encoding has changed. This affect both 875 node instance names and instance-identifiers. 877 o I-JSON-related changes. The most significant is the string 878 encoding of 64-bit numbers. 880 o When validating union type, the partial type info present in JSON 881 encoding is taken into account. 883 o Added section about I-JSON compliance. 885 o Updated the example in appendix. 887 o Wrote Security Considerations. 889 o Removed IANA Considerations as there are none. 891 Author's Address 893 Ladislav Lhotka 894 CZ.NIC 896 Email: lhotka@nic.cz