idnits 2.17.1 draft-ietf-appsawg-json-pointer-07.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 (December 11, 2012) is 4126 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: Informational ---------------------------------------------------------------------------- ** 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: Informational K. Zyp 5 Expires: June 14, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 Akamai 8 December 11, 2012 10 JSON Pointer 11 draft-ietf-appsawg-json-pointer-07 13 Abstract 15 JSON Pointer defines a string syntax for identifying a specific value 16 within a 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 June 14, 2013. 35 Copyright Notice 37 Copyright (c) 2012 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 . . . . . . . . . . . . . . . . . . 4 57 6. URI Fragment Identifier Representation . . . . . . . . . . . . 5 58 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 59 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6 60 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 61 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 62 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 64 11.2. Informative References . . . . . . . . . . . . . . . . . . 7 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 4. Evaluation 109 Evaluation of a JSON Pointer begins with a reference to the root 110 value of a JSON document and completes with a reference to some value 111 within the document. Each reference token in the JSON Pointer is 112 sequentially evaluated. By performing the substitutions in this 113 order, an implementation avoids the error of turning '~01' first into 114 '~1' and then into '/', which would be incorrect (the string '~01' 115 correctly becomes '~1' after transformation). 117 Evaluation of each reference token begins by decoding any escaped 118 character sequence; this is performed by first transforming any 119 occurrence of the sequence '~1' to '/', then transforming any 120 occurrence of the sequence '~0' to '~'. 122 The reference token then modifies which value is referenced according 123 to the following scheme: 125 o If the currently referenced value is a JSON object, the new 126 referenced value is the object member with the name identified by 127 the reference token. The member name is equal to the token if it 128 has the same number of Unicode characters as token and their code 129 points are position-wise equal. No Unicode character 130 normalization is performed. If a referenced member name is not 131 unique in an object, the member that is referenced is undefined, 132 and evaluation fails (see below). 134 o If the currently referenced value is a JSON array, the reference 135 token MUST contain either: 137 * characters that represent an unsigned base-10 integer value 138 (possibly with leading zeros), making the new referenced value 139 the array element with the zero-based index identified by the 140 token, or 142 * exactly the single character "-", making the new referenced 143 value the (non-existant) member after the last array element. 145 If a reference token is being evaluated against a JSON document, 146 implementations will evaluate each token against the document's 147 contents, and terminate evaluation with an error condition if it 148 fails to resolve a concrete value for any of the JSON pointer's 149 reference tokens. See Section 7 for details. 151 Note that the use of the "-" character to index an array will always 152 result in such an error; applications of JSON Pointer thus need to 153 specify how it is to be handled, if it is to be useful. 155 5. JSON String Representation 157 A JSON Pointer can be represented in a JSON string value. Per 158 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 159 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 160 escaped. 162 Note that before processing a JSON string as a JSON Pointer, 163 backslash escape sequences must be unescaped. 165 For example, given the JSON document 167 { 168 "foo": ["bar", "baz"], 169 "": 0, 170 "a/b": 1, 171 "c%d": 2, 172 "e^f": 3, 173 "g|h": 4, 174 "i\\j": 5, 175 "k\"l": 6, 176 " ": 7, 177 "m~n": 8 178 } 180 Then the following JSON strings evaluate to the accompanying values: 182 "" // the whole document 183 "/foo" ["bar", "baz"] 184 "/foo/0" "bar" 185 "/" 0 186 "/a~1b" 1 187 "/c%d" 2 188 "/e^f" 3 189 "/g|h" 4 190 "/i\\j" 5 191 "/k\"l" 6 192 "/ " 7 193 "/m~0n" 8 195 6. URI Fragment Identifier Representation 197 A JSON Pointer can be represented in a URI fragment identifier by 198 encoding it into octets, using UTF-8 [RFC3629], percent-encoding 199 those characters not allowed by the fragment rule in [RFC3986]. 201 Note that a given media type needs to nominate JSON Pointer as its 202 fragment identifier syntax explicitly (usually, in its registration 203 [RFC4288]); i.e., just because a document is JSON does not imply that 204 JSON Pointer can be used as its fragment identifier syntax. In 205 particular, the fragment identifier syntax for application/json is 206 not JSON Pointer. 208 Given the same example document as above, the following URI fragment 209 identifiers evaluate to the accompanying values: 211 # // the whole document 212 #/foo ["bar", "baz"] 213 #/foo/0 "bar" 214 #/ 0 215 #/a~1b 1 216 #/c%25d 2 217 #/e%5Ef 3 218 #/g%7Ch 4 219 #/i%5Cj 5 220 #/k%22l 6 221 #/%20 7 222 #/m~0n 8 224 7. Error Handling 226 In the event of an error condition, evaluation of the JSON Pointer 227 fails to complete. 229 This includes, but is not limited to: 231 o Invalid pointer syntax 233 o A pointer that references a non-existent value 235 This specification does not define how errors are handled; an 236 application of JSON Pointer SHOULD specify the impact and handling of 237 each type of error. 239 For example, some applications might stop pointer processing upon an 240 error; others may attempt to recover from missing values by inserting 241 default ones. 243 8. IANA Considerations 245 This document has no impact upon IANA. 247 9. Security Considerations 249 A given JSON Pointer is not guaranteed to reference an actual JSON 250 value. Therefore, applications using JSON Pointer should anticipate 251 this by defining how a pointer that does not resolve ought to be 252 handled. 254 Note that JSON pointers can contain the NUL (Unicode U+0000) 255 character. Care is needed not to misinterpret this character in 256 programming languages that use NUL to mark the end of a string. 258 10. Acknowledgements 260 The following individuals contributed ideas, feedback and wording to 261 this specification: 263 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 264 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 265 Reschke. 267 11. References 269 11.1. Normative References 271 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 272 Requirement Levels", BCP 14, RFC 2119, March 1997. 274 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 275 10646", STD 63, RFC 3629, November 2003. 277 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 278 Resource Identifier (URI): Generic Syntax", STD 66, 279 RFC 3986, January 2005. 281 [RFC4627] Crockford, D., "The application/json Media Type for 282 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 284 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 285 Specifications: ABNF", STD 68, RFC 5234, January 2008. 287 11.2. Informative References 289 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 290 Registration Procedures", BCP 13, RFC 4288, December 2005. 292 Authors' Addresses 294 Paul C. Bryan (editor) 295 Salesforce.com 297 Phone: +1 604 783 1481 298 Email: pbryan@anode.ca 300 Kris Zyp 301 SitePen (USA) 303 Phone: +1 650 968 8787 304 Email: kris@sitepen.com 306 Mark Nottingham (editor) 307 Akamai 309 Email: mnot@mnot.net