idnits 2.17.1 draft-jonas-json-template-language-01.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 : ---------------------------------------------------------------------------- ** There are 4 instances of too long lines in the document, the longest one being 79 characters in excess of 72. ** The abstract seems to contain references ([2], [1]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (March 29, 2019) is 1852 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- -- Looks like a reference, but probably isn't: '1' on line 260 -- Looks like a reference, but probably isn't: '2' on line 262 -- Looks like a reference, but probably isn't: '3' on line 265 -- Looks like a reference, but probably isn't: '4' on line 268 -- Looks like a reference, but probably isn't: '0' on line 136 -- Looks like a reference, but probably isn't: '5' on line 270 -- Looks like a reference, but probably isn't: '6' on line 272 -- Looks like a reference, but probably isn't: '7' on line 274 Summary: 2 errors (**), 0 flaws (~~), 1 warning (==), 9 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group S. Jonas 3 Internet-Draft ETC Labs Core 4 Intended status: Informational March 29, 2019 5 Expires: September 30, 2019 7 JSON Template Language 8 draft-jonas-json-template-language-01 10 Abstract 12 JSON Template Language is a simple, compact template language to 13 substitute JSON [1] into a template. It is derived from the template 14 literals of Javascript, as defined in the ECMAScript Programming 15 Language Standard, Ninth Edition ECMA-262 [2]. It has uses not 16 limited to: specifying interfaces, runtime expression mapping, and 17 other forms of programmatically interacting with JSON and templates. 19 Status of This Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at https://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on September 30, 2019. 36 Copyright Notice 38 Copyright (c) 2019 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (https://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 54 2. Conventions and Definitions . . . . . . . . . . . . . . . . . 2 55 3. Security Considerations . . . . . . . . . . . . . . . . . . . 3 56 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 3 57 5. Example Usage . . . . . . . . . . . . . . . . . . . . . . . . 3 58 5.1. Accessing Array indicies . . . . . . . . . . . . . . . . 3 59 5.2. Accessing Nested Objects and Arrays . . . . . . . . . . . 4 60 6. JSON Template Grammar . . . . . . . . . . . . . . . . . . . . 4 61 6.1. Template literal . . . . . . . . . . . . . . . . . . . . 5 62 6.2. Identifier . . . . . . . . . . . . . . . . . . . . . . . 5 63 6.3. Path . . . . . . . . . . . . . . . . . . . . . . . . . . 5 64 6.4. Array Index . . . . . . . . . . . . . . . . . . . . . . . 5 65 6.5. Head . . . . . . . . . . . . . . . . . . . . . . . . . . 6 66 6.6. Tail . . . . . . . . . . . . . . . . . . . . . . . . . . 6 67 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 6 68 7.1. Normative References . . . . . . . . . . . . . . . . . . 6 69 7.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 6 70 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 7 72 1. Introduction 74 JSON Template Language provides a mechanism for describing various 75 parts of a template by using familiar syntax from Javascript and 76 JSON. By using a familiar syntax we can get interoperability within 77 the JSON [3] and URI [4] specifications. 79 The terms "string", "object" and "array" are from the conventions of 80 Javascript and JSON. 82 A JSON Template provides a structural description of a template, and 83 when JSON is provided, machine-readable instructions on how to 84 construct a string corresponding to those values. A template is 85 transformed into a string by replacing each of the template literals 86 with the corresponding JSON values. 88 2. Conventions and Definitions 90 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 91 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 92 "OPTIONAL" in this document are to be interpreted as described in BCP 93 14 [RFC2119] [RFC8174] when, and only when, they appear in all 94 capitals, as shown here. 96 3. Security Considerations 98 When considering runtime security of JSON Template Language, the 99 surface area is only expanding JSON value by key. No loops or 100 operator grammar is defined and should be avoided in runtime 101 contexts. 103 4. IANA Considerations 105 This document has no IANA actions. 107 5. Example Usage 109 for the given JSON: 111 { 112 "query": { 113 "number": 1, 114 "salad": "potato" 115 } 116 } 118 and the given template: 120 number${query.number}salad${query.salad} 121 \__________/ \__________/ 122 | | 123 | | 124 For each key in given JSON, substitute it by key into the string. 126 expansion: 128 number1saladpotato 130 5.1. Accessing Array indicies 132 for the given JSON 134 { 135 "query": { 136 "numbers": [0, 1, 2, 3], 137 "salads": ["caesar", "potato"] 138 } 139 } 141 and the given template: 143 number${query.numbers[1]}salad${query.salads[1]} 144 \_____________/ \_____________/ 145 | | 146 | | 147 For each key in given JSON, substitute it by array index into the string. 149 expansion: 151 number1saladpotato 153 5.2. Accessing Nested Objects and Arrays 155 for the given JSON 157 { 158 "nested": { 159 "query": { 160 "number": 1, 161 "salads": ["caesar", "potato"] 162 } 163 } 164 } 166 and the given template: 168 number${query.numbers[1]}salad${query.salads[1]} 169 \_____________/ \_____________/ 170 | | 171 | | 172 For each key in given JSON, substitute it by path first. then array index into the string. 174 expansion: 176 number1saladpotato 178 6. JSON Template Grammar 180 Language Grammar defined in ABNF [5] 182 grammar = *( [head] template-head identifier *["." path] *[array-left array-index array-right] template-tail [tail] ) 183 template-head = "${" 184 template-tail = "}" 185 identifier = *( ALPHA / "_" ) 186 path = *( ALPHA / "_" ) 187 array-left = "[" 188 array-right = "]" 189 array-index = *( DIGIT ) 190 head = *( ALPHA / DIGIT / special-characters ) 191 tail = *( ALPHA / DIGIT / special-characters ) 192 special-characters = *("-" / "_" / "~" / "." / ":" / "/" / "?" / "#" / "[" / "]" / "@" / "!" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=") 194 6.1. Template literal 196 The contents within the Template literal should be valid a key-value 197 object mapping or array-index mapping for JSON [6]. 199 grammar = *( [head] template-head identifier *["." path] \ 200 [array-left array-index array-right] template-tail [tail] ) 202 A template literal is represented within a URIs [7] as a pair of 203 curly braces starting with a "$". 205 template-head = "${" 206 template-tail = "}" 208 6.2. Identifier 210 An identifier is a valid JSON key. 212 identifier = *( ALPHA / "_" ) 214 6.3. Path 216 MUST be a valid nested JSON key that will be resolved with the 217 identifier. 219 *["." path] 221 6.4. Array Index 223 MUST be a valid index of a JSON array are represented within square 224 brackets and MUST be a valid number. 226 *[array-left array-index array-right] 227 array-left = "[" 228 array-right = "]" 229 array-index = *( DIGIT ) 231 6.5. Head 233 Head represents the characters before template-head, this could be 234 beginning of the template or the last tail. 236 head = *( ALPHA / DIGIT / special-characters ) 238 6.6. Tail 240 Tail represents the characters after the template-tail until the end 241 of the template or the next instance of a template literal. 243 tail = *( ALPHA / DIGIT / special-characters ) 245 7. References 247 7.1. Normative References 249 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 250 Requirement Levels", BCP 14, RFC 2119, 251 DOI 10.17487/RFC2119, March 1997, 252 . 254 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 255 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 256 May 2017, . 258 7.2. URIs 260 [1] https://tools.ietf.org/html/rfc7159 262 [2] https://www.ecma-international.org/ecma-262/9.0/index.html#sec- 263 template-literals 265 [3] https://tools.ietf.org/html/rfc7159, https://www.ecma- 266 international.org/ecma-262/9.0/index.html#sec-template-literals 268 [4] https://tools.ietf.org/html/rfc6570 270 [5] https://tools.ietf.org/html/rfc5234 272 [6] https://tools.ietf.org/html/rfc7159 274 [7] https://tools.ietf.org/html/rfc3986 276 Author's Address 278 Shane Jonas 279 ETC Labs Core 281 Email: shane.j@etclabs.org