draft-ietf-netmod-yang-json-06.txt | draft-ietf-netmod-yang-json-07.txt | |||
---|---|---|---|---|
NETMOD Working Group L. Lhotka | NETMOD Working Group L. Lhotka | |||
Internet-Draft CZ.NIC | Internet-Draft CZ.NIC | |||
Intended status: Standards Track October 07, 2015 | Intended status: Standards Track January 28, 2016 | |||
Expires: April 9, 2016 | Expires: July 31, 2016 | |||
JSON Encoding of Data Modeled with YANG | JSON Encoding of Data Modeled with YANG | |||
draft-ietf-netmod-yang-json-06 | draft-ietf-netmod-yang-json-07 | |||
Abstract | Abstract | |||
This document defines encoding rules for representing configuration, | This document defines encoding rules for representing configuration, | |||
state data, RPC operation or action input and output parameters, and | state data, RPC operation or action input and output parameters, and | |||
notifications defined using YANG as JavaScript Object Notation (JSON) | notifications defined using YANG as JavaScript Object Notation (JSON) | |||
text. | text. | |||
Status of This Memo | Status of This Memo | |||
skipping to change at page 1, line 33 | skipping to change at page 1, line 33 | |||
Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
Drafts is at http://datatracker.ietf.org/drafts/current/. | Drafts is at http://datatracker.ietf.org/drafts/current/. | |||
Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
This Internet-Draft will expire on April 9, 2016. | This Internet-Draft will expire on July 31, 2016. | |||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2015 IETF Trust and the persons identified as the | Copyright (c) 2016 IETF Trust and the persons identified as the | |||
document authors. All rights reserved. | document authors. All rights reserved. | |||
This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
(http://trustee.ietf.org/license-info) in effect on the date of | (http://trustee.ietf.org/license-info) in effect on the date of | |||
publication of this document. Please review these documents | publication of this document. Please review these documents | |||
carefully, as they describe your rights and restrictions with respect | carefully, as they describe your rights and restrictions with respect | |||
to this document. Code Components extracted from this document must | to this document. Code Components extracted from this document must | |||
include Simplified BSD License text as described in Section 4.e of | include Simplified BSD License text as described in Section 4.e of | |||
the Trust Legal Provisions and are provided without warranty as | the Trust Legal Provisions and are provided without warranty as | |||
skipping to change at page 2, line 18 | skipping to change at page 2, line 18 | |||
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 | 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 | |||
3. Properties of the JSON Encoding . . . . . . . . . . . . . . . 4 | 3. Properties of the JSON Encoding . . . . . . . . . . . . . . . 4 | |||
4. Names and Namespaces . . . . . . . . . . . . . . . . . . . . 4 | 4. Names and Namespaces . . . . . . . . . . . . . . . . . . . . 4 | |||
5. Encoding of YANG Data Node Instances . . . . . . . . . . . . 6 | 5. Encoding of YANG Data Node Instances . . . . . . . . . . . . 6 | |||
5.1. The "leaf" Data Node . . . . . . . . . . . . . . . . . . 7 | 5.1. The "leaf" Data Node . . . . . . . . . . . . . . . . . . 7 | |||
5.2. The "container" Data Node . . . . . . . . . . . . . . . . 7 | 5.2. The "container" Data Node . . . . . . . . . . . . . . . . 7 | |||
5.3. The "leaf-list" Data Node . . . . . . . . . . . . . . . . 7 | 5.3. The "leaf-list" Data Node . . . . . . . . . . . . . . . . 7 | |||
5.4. The "list" Data Node . . . . . . . . . . . . . . . . . . 8 | 5.4. The "list" Data Node . . . . . . . . . . . . . . . . . . 8 | |||
5.5. The "anydata" Data Node . . . . . . . . . . . . . . . . . 9 | 5.5. The "anydata" Data Node . . . . . . . . . . . . . . . . . 9 | |||
5.6. The "anyxml" Data Node . . . . . . . . . . . . . . . . . 10 | 5.6. The "anyxml" Data Node . . . . . . . . . . . . . . . . . 10 | |||
5.7. Metadata Objects . . . . . . . . . . . . . . . . . . . . 10 | ||||
6. Representing YANG Data Types in JSON Values . . . . . . . . . 10 | 6. Representing YANG Data Types in JSON Values . . . . . . . . . 10 | |||
6.1. Numeric Types . . . . . . . . . . . . . . . . . . . . . . 10 | 6.1. Numeric Types . . . . . . . . . . . . . . . . . . . . . . 10 | |||
6.2. The "string" Type . . . . . . . . . . . . . . . . . . . . 11 | 6.2. The "string" Type . . . . . . . . . . . . . . . . . . . . 11 | |||
6.3. The "boolean" Type . . . . . . . . . . . . . . . . . . . 11 | 6.3. The "boolean" Type . . . . . . . . . . . . . . . . . . . 11 | |||
6.4. The "enumeration" Type . . . . . . . . . . . . . . . . . 11 | 6.4. The "enumeration" Type . . . . . . . . . . . . . . . . . 11 | |||
6.5. The "bits" Type . . . . . . . . . . . . . . . . . . . . . 11 | 6.5. The "bits" Type . . . . . . . . . . . . . . . . . . . . . 11 | |||
6.6. The "binary" Type . . . . . . . . . . . . . . . . . . . . 11 | 6.6. The "binary" Type . . . . . . . . . . . . . . . . . . . . 11 | |||
6.7. The "leafref" Type . . . . . . . . . . . . . . . . . . . 12 | 6.7. The "leafref" Type . . . . . . . . . . . . . . . . . . . 12 | |||
6.8. The "identityref" Type . . . . . . . . . . . . . . . . . 12 | 6.8. The "identityref" Type . . . . . . . . . . . . . . . . . 12 | |||
6.9. The "empty" Type . . . . . . . . . . . . . . . . . . . . 12 | 6.9. The "empty" Type . . . . . . . . . . . . . . . . . . . . 12 | |||
skipping to change at page 2, line 39 | skipping to change at page 2, line 40 | |||
6.11. The "instance-identifier" Type . . . . . . . . . . . . . 14 | 6.11. The "instance-identifier" Type . . . . . . . . . . . . . 14 | |||
7. I-JSON Compliance . . . . . . . . . . . . . . . . . . . . . . 14 | 7. I-JSON Compliance . . . . . . . . . . . . . . . . . . . . . . 14 | |||
8. Security Considerations . . . . . . . . . . . . . . . . . . . 15 | 8. Security Considerations . . . . . . . . . . . . . . . . . . . 15 | |||
9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 15 | 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 15 | |||
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 | 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 | |||
10.1. Normative References . . . . . . . . . . . . . . . . . . 15 | 10.1. Normative References . . . . . . . . . . . . . . . . . . 15 | |||
10.2. Informative References . . . . . . . . . . . . . . . . . 16 | 10.2. Informative References . . . . . . . . . . . . . . . . . 16 | |||
Appendix A. A Complete Example . . . . . . . . . . . . . . . . . 16 | Appendix A. A Complete Example . . . . . . . . . . . . . . . . . 16 | |||
Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 18 | Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 18 | |||
B.1. Changes Between Revisions -05 and -06 . . . . . . . . . . 18 | B.1. Changes Between Revisions -05 and -06 . . . . . . . . . . 18 | |||
B.2. Changes Between Revisions -04 and -05 . . . . . . . . . . 18 | B.2. Changes Between Revisions -05 and -06 . . . . . . . . . . 19 | |||
B.3. Changes Between Revisions -03 and -04 . . . . . . . . . . 19 | B.3. Changes Between Revisions -04 and -05 . . . . . . . . . . 19 | |||
B.4. Changes Between Revisions -02 and -03 . . . . . . . . . . 19 | B.4. Changes Between Revisions -03 and -04 . . . . . . . . . . 19 | |||
B.5. Changes Between Revisions -01 and -02 . . . . . . . . . . 19 | B.5. Changes Between Revisions -02 and -03 . . . . . . . . . . 19 | |||
B.6. Changes Between Revisions -00 and -01 . . . . . . . . . . 19 | B.6. Changes Between Revisions -01 and -02 . . . . . . . . . . 19 | |||
B.7. Changes Between Revisions -00 and -01 . . . . . . . . . . 19 | ||||
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 20 | Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 20 | |||
1. Introduction | 1. Introduction | |||
The NETCONF protocol [RFC6241] uses XML [W3C.REC-xml-20081126] for | The NETCONF protocol [RFC6241] uses XML [W3C.REC-xml-20081126] for | |||
encoding data in its Content Layer. Other management protocols might | encoding data in its Content Layer. Other management protocols might | |||
want to use other encodings while still benefiting from using YANG | want to use other encodings while still benefiting from using YANG | |||
[I-D.ietf-netmod-rfc6020bis] as the data modeling language. | [I-D.ietf-netmod-rfc6020bis] as the data modeling language. | |||
For example, the RESTCONF protocol [I-D.ietf-netconf-restconf] | For example, the RESTCONF protocol [I-D.ietf-netconf-restconf] | |||
skipping to change at page 10, line 20 | skipping to change at page 10, line 20 | |||
"reporting-entity": { | "reporting-entity": { | |||
"card": "Ethernet0" | "card": "Ethernet0" | |||
}, | }, | |||
"severity": "major" | "severity": "major" | |||
} | } | |||
} | } | |||
} | } | |||
5.6. The "anyxml" Data Node | 5.6. The "anyxml" Data Node | |||
An anyxml instance is encoded as a JSON name/value pair which MUST | An anyxml instance is encoded as a JSON name/value pair. The value | |||
satisfy I-JSON constraints. Otherwise it is unrestricted, i.e., the | MUST satisfy I-JSON constraints. | |||
value can be an object, array, number, string or one of the literals | ||||
"true", "false" and "null". | ||||
There is no universal procedure for mapping JSON-encoded anyxml | ||||
instances to XML, and vice versa. | ||||
Example: For the anyxml definition | Example: For the anyxml definition | |||
anyxml bar; | anyxml bar; | |||
the following is a valid JSON-encoded instance: | the following is a valid JSON-encoded instance: | |||
"bar": [true, null, true] | "bar": [true, null, true] | |||
5.7. Metadata Objects | ||||
Apart from instances of YANG data nodes, a JSON document MAY contain | ||||
special object members whose name starts with the "@" character | ||||
(COMMERCIAL AT). Such members are used for special purposes such as | ||||
encoding metadata [I-D.ietf-netmod-yang-metadata]. Exact syntax and | ||||
semantics of such members are outside the scope of this document. | ||||
6. Representing YANG Data Types in JSON Values | 6. Representing YANG Data Types in JSON Values | |||
The type of the JSON value in an instance of the leaf or leaf-list | The type of the JSON value in an instance of the leaf or leaf-list | |||
data node depends on the type of that data node as specified in the | data node depends on the type of that data node as specified in the | |||
following subsections. | following subsections. | |||
6.1. Numeric Types | 6.1. Numeric Types | |||
A value of the types "int8", "int16", "int32", "uint8", "uint16" and | A value of the types "int8", "int16", "int32", "uint8", "uint16" and | |||
"uint32" is represented as a JSON number. | "uint32" is represented as a JSON number. | |||
skipping to change at page 15, line 36 | skipping to change at page 15, line 36 | |||
The author wishes to thank Andy Bierman, Martin Bjorklund, Dean | The author wishes to thank Andy Bierman, Martin Bjorklund, Dean | |||
Bogdanovic, Balazs Lengyel, Juergen Schoenwaelder and Phil Shafer for | Bogdanovic, Balazs Lengyel, Juergen Schoenwaelder and Phil Shafer for | |||
their helpful comments and suggestions. | their helpful comments and suggestions. | |||
10. References | 10. References | |||
10.1. Normative References | 10.1. Normative References | |||
[I-D.ietf-netmod-rfc6020bis] | [I-D.ietf-netmod-rfc6020bis] | |||
Bjorklund, M., "The YANG 1.1 Data Modeling Language", | Bjorklund, M., "The YANG 1.1 Data Modeling Language", | |||
draft-ietf-netmod-rfc6020bis-07 (work in progress), | draft-ietf-netmod-rfc6020bis-09 (work in progress), | |||
September 2015. | December 2015. | |||
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ | Requirement Levels", BCP 14, RFC 2119, | |||
RFC2119, March 1997, | DOI 10.17487/RFC2119, March 1997, | |||
<http://www.rfc-editor.org/info/rfc2119>. | <http://www.rfc-editor.org/info/rfc2119>. | |||
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax | [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax | |||
Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/ | Specifications: ABNF", STD 68, RFC 5234, | |||
RFC5234, January 2008, | DOI 10.17487/RFC5234, January 2008, | |||
<http://www.rfc-editor.org/info/rfc5234>. | <http://www.rfc-editor.org/info/rfc5234>. | |||
[RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., | [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., | |||
and A. Bierman, Ed., "Network Configuration Protocol | and A. Bierman, Ed., "Network Configuration Protocol | |||
(NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, | (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, | |||
<http://www.rfc-editor.org/info/rfc6241>. | <http://www.rfc-editor.org/info/rfc6241>. | |||
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data | [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data | |||
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March | Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March | |||
2014, <http://www.rfc-editor.org/info/rfc7159>. | 2014, <http://www.rfc-editor.org/info/rfc7159>. | |||
[RFC7493] Bray, T., Ed., "The I-JSON Message Format", RFC 7493, DOI | [RFC7493] Bray, T., Ed., "The I-JSON Message Format", RFC 7493, | |||
10.17487/RFC7493, March 2015, | DOI 10.17487/RFC7493, March 2015, | |||
<http://www.rfc-editor.org/info/rfc7493>. | <http://www.rfc-editor.org/info/rfc7493>. | |||
10.2. Informative References | 10.2. Informative References | |||
[I-D.ietf-netconf-restconf] | [I-D.ietf-netconf-restconf] | |||
Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF | Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF | |||
Protocol", draft-ietf-netconf-restconf-07 (work in | Protocol", draft-ietf-netconf-restconf-09 (work in | |||
progress), July 2015. | progress), December 2015. | |||
[I-D.ietf-netmod-yang-metadata] | ||||
Lhotka, L., "Defining and Using Metadata with YANG", | ||||
draft-ietf-netmod-yang-metadata-02 (work in progress), | ||||
September 2015. | ||||
[RFC7223] Bjorklund, M., "A YANG Data Model for Interface | [RFC7223] Bjorklund, M., "A YANG Data Model for Interface | |||
Management", RFC 7223, DOI 10.17487/RFC7223, May 2014, | Management", RFC 7223, DOI 10.17487/RFC7223, May 2014, | |||
<http://www.rfc-editor.org/info/rfc7223>. | <http://www.rfc-editor.org/info/rfc7223>. | |||
[W3C.REC-xml-20081126] | [W3C.REC-xml-20081126] | |||
Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and | Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and | |||
F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth | F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth | |||
Edition)", World Wide Web Consortium Recommendation REC- | Edition)", World Wide Web Consortium Recommendation REC- | |||
xml-20081126, November 2008, | xml-20081126, November 2008, | |||
skipping to change at page 18, line 42 | skipping to change at page 18, line 47 | |||
] | ] | |||
} | } | |||
} | } | |||
Appendix B. Change Log | Appendix B. Change Log | |||
RFC Editor: Remove this section upon publication as an RFC. | RFC Editor: Remove this section upon publication as an RFC. | |||
B.1. Changes Between Revisions -05 and -06 | B.1. Changes Between Revisions -05 and -06 | |||
o General permit on object members whose names start with "@". | ||||
B.2. Changes Between Revisions -05 and -06 | ||||
o More text and a new example about resolving union-type values. | o More text and a new example about resolving union-type values. | |||
B.2. Changes Between Revisions -04 and -05 | B.3. Changes Between Revisions -04 and -05 | |||
o Removed section "Validation of JSON-encoded Instance Data" and | o Removed section "Validation of JSON-encoded Instance Data" and | |||
other text about XML-JSON mapping. | other text about XML-JSON mapping. | |||
o Added section "Properties of the JSON Encoding". | o Added section "Properties of the JSON Encoding". | |||
B.3. Changes Between Revisions -03 and -04 | B.4. Changes Between Revisions -03 and -04 | |||
o I-D.ietf-netmod-rfc6020bis is used as a normative reference | o I-D.ietf-netmod-rfc6020bis is used as a normative reference | |||
instead of RFC 6020. | instead of RFC 6020. | |||
o Removed noncharacters as an I-JSON issue because it doesn't exist | o Removed noncharacters as an I-JSON issue because it doesn't exist | |||
in YANG 1.1. | in YANG 1.1. | |||
o Section about anydata encoding was added. | o Section about anydata encoding was added. | |||
o Require I-JSON for anyxml encoding. | o Require I-JSON for anyxml encoding. | |||
o Use ABNF for defining qualified name. | o Use ABNF for defining qualified name. | |||
B.4. Changes Between Revisions -02 and -03 | B.5. Changes Between Revisions -02 and -03 | |||
o Namespace encoding is defined without using RFC 2119 keywords. | o Namespace encoding is defined without using RFC 2119 keywords. | |||
o Specification for anyxml nodes was extended and clarified. | o Specification for anyxml nodes was extended and clarified. | |||
o Text about ordering of list entries was corrected. | o Text about ordering of list entries was corrected. | |||
B.5. Changes Between Revisions -01 and -02 | B.6. Changes Between Revisions -01 and -02 | |||
o Encoding of namespaces in instance-identifiers was changed. | o Encoding of namespaces in instance-identifiers was changed. | |||
o Text specifying the order of array elements in leaf-list and list | o Text specifying the order of array elements in leaf-list and list | |||
instances was added. | instances was added. | |||
B.6. Changes Between Revisions -00 and -01 | B.7. Changes Between Revisions -00 and -01 | |||
o Metadata encoding was moved to a separate I-D, draft-lhotka- | o Metadata encoding was moved to a separate I-D, draft-lhotka- | |||
netmod-yang-metadata. | netmod-yang-metadata. | |||
o JSON encoding is now defined directly rather than via XML-JSON | o JSON encoding is now defined directly rather than via XML-JSON | |||
mapping. | mapping. | |||
o The rules for namespace encoding has changed. This affect both | o The rules for namespace encoding has changed. This affect both | |||
node instance names and instance-identifiers. | node instance names and instance-identifiers. | |||
End of changes. 19 change blocks. | ||||
32 lines changed or deleted | 46 lines changed or added | |||
This html diff was produced by rfcdiff 1.42. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |