idnits 2.17.1 draft-ietf-appsawg-json-pointer-08.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 4, 2013) is 4130 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 8, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 Akamai 8 January 4, 2013 10 JavaScript Object Notation (JSON) Pointer 11 draft-ietf-appsawg-json-pointer-08 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 8, 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 . . . . . . . . . . . . . . . . . . . . . . . . 6 59 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7 60 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 61 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 62 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 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 token and their code 132 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 terminate evaluation with an error condition 156 if it fails to resolve a concrete value for any of the JSON pointer's 157 reference tokens. For example, if an array is referenced with a non- 158 numeric token, it will fail. 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; applications of JSON Pointer thus need to 162 specify how it is to be handled, if it is to be useful. 164 5. JSON String Representation 166 A JSON Pointer can be represented in a JSON string value. Per 167 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 168 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 169 escaped. 171 Note that before processing a JSON string as a JSON Pointer, 172 backslash escape sequences must be unescaped. 174 For example, given the JSON document 176 { 177 "foo": ["bar", "baz"], 178 "": 0, 179 "a/b": 1, 180 "c%d": 2, 181 "e^f": 3, 182 "g|h": 4, 183 "i\\j": 5, 184 "k\"l": 6, 185 " ": 7, 186 "m~n": 8 187 } 189 Then the following JSON strings evaluate to the accompanying values: 191 "" // the whole document 192 "/foo" ["bar", "baz"] 193 "/foo/0" "bar" 194 "/" 0 195 "/a~1b" 1 196 "/c%d" 2 197 "/e^f" 3 198 "/g|h" 4 199 "/i\\j" 5 200 "/k\"l" 6 201 "/ " 7 202 "/m~0n" 8 204 6. URI Fragment Identifier Representation 206 A JSON Pointer can be represented in a URI fragment identifier by 207 encoding it into octets using UTF-8 [RFC3629], percent-encoding those 208 characters not allowed by the fragment rule in [RFC3986]. 210 Note that a given media type needs to specify JSON Pointer as its 211 fragment identifier syntax explicitly (usually, in its registration 212 [RFC4288]); i.e., just because a document is JSON does not imply that 213 JSON Pointer can be used as its fragment identifier syntax. In 214 particular, the fragment identifier syntax for application/json is 215 not JSON Pointer. 217 Given the same example document as above, the following URI fragment 218 identifiers evaluate to the accompanying values: 220 # // the whole document 221 #/foo ["bar", "baz"] 222 #/foo/0 "bar" 223 #/ 0 224 #/a~1b 1 225 #/c%25d 2 226 #/e%5Ef 3 227 #/g%7Ch 4 228 #/i%5Cj 5 229 #/k%22l 6 230 #/%20 7 231 #/m~0n 8 233 7. Error Handling 235 In the event of an error condition, evaluation of the JSON Pointer 236 fails to complete. 238 This includes, but is not limited to: 240 o Invalid pointer syntax 242 o A pointer that references a non-existent value 244 This specification does not define how errors are handled; an 245 application of JSON Pointer SHOULD specify the impact and handling of 246 each type of error. 248 For example, some applications might stop pointer processing upon an 249 error; others may attempt to recover from missing values by inserting 250 default ones. 252 8. IANA Considerations 254 This document has no impact upon IANA. 256 9. Security Considerations 258 A given JSON Pointer is not guaranteed to reference an actual JSON 259 value. Therefore, applications using JSON Pointer should anticipate 260 this by defining how a pointer that does not resolve ought to be 261 handled. 263 Note that JSON pointers can contain the NUL (Unicode U+0000) 264 character. Care is needed not to misinterpret this character in 265 programming languages that use NUL to mark the end of a string. 267 10. Acknowledgements 269 The following individuals contributed ideas, feedback and wording to 270 this specification: 272 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 273 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 274 Reschke. 276 11. References 278 11.1. Normative References 280 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 281 Requirement Levels", BCP 14, RFC 2119, March 1997. 283 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 284 10646", STD 63, RFC 3629, November 2003. 286 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 287 Resource Identifier (URI): Generic Syntax", STD 66, 288 RFC 3986, January 2005. 290 [RFC4627] Crockford, D., "The application/json Media Type for 291 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 293 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 294 Specifications: ABNF", STD 68, RFC 5234, January 2008. 296 11.2. Informative References 298 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 299 Registration Procedures", BCP 13, RFC 4288, December 2005. 301 Authors' Addresses 303 Paul C. Bryan (editor) 304 Salesforce.com 306 Phone: +1 604 783 1481 307 Email: pbryan@anode.ca 309 Kris Zyp 310 SitePen (USA) 312 Phone: +1 650 968 8787 313 Email: kris@sitepen.com 315 Mark Nottingham (editor) 316 Akamai 318 Email: mnot@mnot.net