idnits 2.17.1 draft-ietf-appsawg-json-pointer-09.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 : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (January 22, 2013) is 4084 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) -- Obsolete informational reference (is this intentional?): RFC 4288 (Obsoleted by RFC 6838) Summary: 1 error (**), 0 flaws (~~), 1 warning (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Applications Area Working Group P. Bryan, Ed. 3 Internet-Draft Salesforce.com 4 Intended status: Standards Track K. Zyp 5 Expires: July 26, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 Akamai 8 January 22, 2013 10 JavaScript Object Notation (JSON) Pointer 11 draft-ietf-appsawg-json-pointer-09 13 Abstract 15 JSON Pointer defines a string syntax for identifying a specific value 16 within a JavaScript Object Notation (JSON) document. 18 Status of this Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at http://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on July 26, 2013. 35 Copyright Notice 37 Copyright (c) 2013 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (http://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 53 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 54 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 55 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 56 5. JSON String Representation . . . . . . . . . . . . . . . . . . 5 57 6. URI Fragment Identifier Representation . . . . . . . . . . . . 6 58 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 7 59 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7 60 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 61 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 62 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 8 63 11.1. Normative References . . . . . . . . . . . . . . . . . . . 8 64 11.2. Informative References . . . . . . . . . . . . . . . . . . 8 65 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 8 67 1. Introduction 69 This specification defines JSON Pointer, a string syntax for 70 identifying a specific value within a JavaScript Object Notation 71 (JSON) [RFC4627] document. It is intended to be easily expressed in 72 JSON string values as well as Uniform Resource Identifier (URI) 73 [RFC3986] fragment identifiers. 75 2. Conventions 77 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 78 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 79 document are to be interpreted as described in [RFC2119]. 81 This specification expresses normative syntax rules using Augmented 82 Backus-Naur Form (ABNF) [RFC5234] notation. 84 3. Syntax 86 A JSON Pointer is a Unicode string (see [RFC4627], Section 3) 87 containing a sequence of zero or more reference tokens, each prefixed 88 by a '/' (%x2F) character. 90 Because the characters '~' (%x7E) and '/' (%x2F) have special 91 meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/' 92 needs to be encoded as '~1' when these characters appear in a 93 reference token. 95 The ABNF syntax of a JSON Pointer is: 97 json-pointer = *( "/" reference-token ) 98 reference-token = *( unescaped / escaped ) 99 unescaped = %x00-2E / %x30-7D / %x7F-10FFFF 100 ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped' 101 escaped = "~" ( "0" / "1" ) 102 ; representing '~' and '/', respectively 104 It is an error condition if a JSON Pointer value does not conform to 105 this syntax (see Section 7). 107 Note that JSON Pointers are specified in characters, not as bytes. 109 4. Evaluation 111 Evaluation of a JSON Pointer begins with a reference to the root 112 value of a JSON document and completes with a reference to some value 113 within the document. Each reference token in the JSON Pointer is 114 sequentially evaluated. 116 Evaluation of each reference token begins by decoding any escaped 117 character sequence; this is performed by first transforming any 118 occurrence of the sequence '~1' to '/', then transforming any 119 occurrence of the sequence '~0' to '~'. By performing the 120 substitutions in this order, an implementation avoids the error of 121 turning '~01' first into '~1' and then into '/', which would be 122 incorrect (the string '~01' correctly becomes '~1' after 123 transformation). 125 The reference token then modifies which value is referenced according 126 to the following scheme: 128 o If the currently referenced value is a JSON object, the new 129 referenced value is the object member with the name identified by 130 the reference token. The member name is equal to the token if it 131 has the same number of Unicode characters as the token and their 132 code points are position-wise equal. No Unicode character 133 normalization is performed. If a referenced member name is not 134 unique in an object, the member that is referenced is undefined, 135 and evaluation fails (see below). 137 o If the currently referenced value is a JSON array, the reference 138 token MUST contain either: 140 * characters comprised of digits (see ABNF below; note that 141 leading zeros are not allowed) that represent an unsigned 142 base-10 integer value, making the new referenced value the 143 array element with the zero-based index identified by the 144 token, or 146 * exactly the single character "-", making the new referenced 147 value the (non-existant) member after the last array element. 149 The ABNF syntax for array indices is: 151 array-index = %x30 / ( %x31-39 *(%x30-39) ) 152 ; "0", or digits without a leading "0" 154 Implementations will evaluate each reference token against the 155 document's contents, and will raise an error condition if it fails to 156 resolve a concrete value for any of the JSON pointer's reference 157 tokens. For example, if an array is referenced with a non-numeric 158 token, an error condition will be raised. See Section 7 for details. 160 Note that the use of the "-" character to index an array will always 161 result in such an error condition because by definition it refers to 162 a non-existent array element. Applications of JSON Pointer thus need 163 to specify how it is to be handled, if it is to be useful. 165 Any error condition that does not have a specific action defined for 166 it by the JSON Pointer application results in termination of 167 evaluation. 169 5. JSON String Representation 171 A JSON Pointer can be represented in a JSON string value. Per 172 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 173 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 174 escaped. 176 Note that before processing a JSON string as a JSON Pointer, 177 backslash escape sequences must be unescaped. 179 For example, given the JSON document 181 { 182 "foo": ["bar", "baz"], 183 "": 0, 184 "a/b": 1, 185 "c%d": 2, 186 "e^f": 3, 187 "g|h": 4, 188 "i\\j": 5, 189 "k\"l": 6, 190 " ": 7, 191 "m~n": 8 192 } 194 Then the following JSON strings evaluate to the accompanying values: 196 "" // the whole document 197 "/foo" ["bar", "baz"] 198 "/foo/0" "bar" 199 "/" 0 200 "/a~1b" 1 201 "/c%d" 2 202 "/e^f" 3 203 "/g|h" 4 204 "/i\\j" 5 205 "/k\"l" 6 206 "/ " 7 207 "/m~0n" 8 209 6. URI Fragment Identifier Representation 211 A JSON Pointer can be represented in a URI fragment identifier by 212 encoding it into octets using UTF-8 [RFC3629], percent-encoding those 213 characters not allowed by the fragment rule in [RFC3986]. 215 Note that a given media type needs to specify JSON Pointer as its 216 fragment identifier syntax explicitly (usually, in its registration 217 [RFC4288]); i.e., just because a document is JSON does not imply that 218 JSON Pointer can be used as its fragment identifier syntax. In 219 particular, the fragment identifier syntax for application/json is 220 not JSON Pointer. 222 Given the same example document as above, the following URI fragment 223 identifiers evaluate to the accompanying values: 225 # // the whole document 226 #/foo ["bar", "baz"] 227 #/foo/0 "bar" 228 #/ 0 229 #/a~1b 1 230 #/c%25d 2 231 #/e%5Ef 3 232 #/g%7Ch 4 233 #/i%5Cj 5 234 #/k%22l 6 235 #/%20 7 236 #/m~0n 8 238 7. Error Handling 240 In the event of an error condition, evaluation of the JSON Pointer 241 fails to complete. 243 This includes, but is not limited to: 245 o Invalid pointer syntax 247 o A pointer that references a non-existent value 249 This specification does not define how errors are handled; an 250 application of JSON Pointer SHOULD specify the impact and handling of 251 each type of error. 253 For example, some applications might stop pointer processing upon an 254 error; others may attempt to recover from missing values by inserting 255 default ones. 257 8. IANA Considerations 259 This document has no impact upon IANA. 261 9. Security Considerations 263 A given JSON Pointer is not guaranteed to reference an actual JSON 264 value. Therefore, applications using JSON Pointer should anticipate 265 this by defining how a pointer that does not resolve ought to be 266 handled. 268 Note that JSON pointers can contain the NUL (Unicode U+0000) 269 character. Care is needed not to misinterpret this character in 270 programming languages that use NUL to mark the end of a string. 272 10. Acknowledgements 274 The following individuals contributed ideas, feedback and wording to 275 this specification: 277 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 278 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 279 Reschke. 281 11. References 282 11.1. Normative References 284 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 285 Requirement Levels", BCP 14, RFC 2119, March 1997. 287 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 288 10646", STD 63, RFC 3629, November 2003. 290 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 291 Resource Identifier (URI): Generic Syntax", STD 66, 292 RFC 3986, January 2005. 294 [RFC4627] Crockford, D., "The application/json Media Type for 295 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 297 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 298 Specifications: ABNF", STD 68, RFC 5234, January 2008. 300 11.2. Informative References 302 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 303 Registration Procedures", BCP 13, RFC 4288, December 2005. 305 Authors' Addresses 307 Paul C. Bryan (editor) 308 Salesforce.com 310 Phone: +1 604 783 1481 311 Email: pbryan@anode.ca 313 Kris Zyp 314 SitePen (USA) 316 Phone: +1 650 968 8787 317 Email: kris@sitepen.com 319 Mark Nottingham (editor) 320 Akamai 322 Email: mnot@mnot.net