idnits 2.17.1 draft-ietf-appsawg-json-pointer-06.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 5, 2012) is 4160 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 8, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 Akamai 8 December 5, 2012 10 JSON Pointer 11 draft-ietf-appsawg-json-pointer-06 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 8, 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 . . . . . . . . . . . . . . . . . . . . 6 61 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 62 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 64 11.2. Informative References . . . . . . . . . . . . . . . . . . 7 65 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 7 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 containing a sequence of zero or 87 more reference tokens, each prefixed by a '/' (%x2F) character. 89 Since the characters '~' (%x7E) and '/' (%x2F) have a special meaning 90 in JSON Pointer, they need to be encoded as '~0' and '~1' 91 respectively, when appearing in a reference token. 93 Its ABNF syntax is: 95 json-pointer = *( "/" reference-token ) 96 reference-token = *( unescaped / escaped ) 97 unescaped = %x00-2E / %x30-7D / %x7F-10FFFF 98 escaped = "~" ( "0" / "1" ) 100 It is an error condition if a JSON Pointer value does not conform to 101 this syntax (see Section 7). 103 4. Evaluation 105 Evaluation of a JSON Pointer begins with a reference to the root 106 value of a JSON document and completes with a reference to some value 107 within the document. Each reference token in the JSON Pointer is 108 sequentially evaluated. 110 Evaluation of each reference token begins by decoding any escaped 111 character sequence; this is performed by first transforming any 112 occurrence of the sequence '~1' to '/', then transforming any 113 occurrence of the sequence '~0' to '~'. 115 The reference token then modifies which value is referenced according 116 to the following scheme: 118 o If the currently referenced value is a JSON object, the new 119 referenced value is the object member with the name identified by 120 the reference token. The member name is equal to the token if it 121 has the same number of Unicode characters as token and their code 122 points are position-wise equal. If a referenced member name is 123 not unique in an object, the member that is referenced is 124 undefined, and evaluation fails (see below). 126 o If the currently referenced value is a JSON array, the reference 127 token MUST contain either: 129 * characters that represent an unsigned base-10 integer value 130 (possibly with leading zeros), making the new referenced value 131 the array element with the zero-based index identified by the 132 token, or 134 * exactly the single character "-", making the new referenced 135 value the (non-existant) member after the last array element. 137 If a reference token is being evaluated against a JSON document, 138 implementations will evaluate each token against the document's 139 contents, and terminate evaluation with an error condition if it 140 fails to resolve a concrete value for any of the JSON pointer's 141 reference tokens. See Section 7 for details. 143 Note that the use of the "-" character to index an array will always 144 result in such an error; applications of JSON Pointer thus need to 145 specify how it is to be handled, if it is to be useful. 147 5. JSON String Representation 149 A JSON Pointer can be represented in a JSON string value. Per 150 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 151 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 152 escaped. 154 Note that before processing a JSON string as a JSON Pointer, 155 backslash escape sequences must be unescaped. 157 For example, given the JSON document 158 { 159 "foo": ["bar", "baz"], 160 "": 0, 161 "a/b": 1, 162 "c%d": 2, 163 "e^f": 3, 164 "g|h": 4, 165 "i\\j": 5, 166 "k\"l": 6, 167 " ": 7, 168 "m~n": 8 169 } 171 Then the following JSON strings evaluate to the accompanying values: 173 "" // the whole document 174 "/foo" ["bar", "baz"] 175 "/foo/0" "bar" 176 "/" 0 177 "/a~1b" 1 178 "/c%d" 2 179 "/e^f" 3 180 "/g|h" 4 181 "/i\\j" 5 182 "/k\"l" 6 183 "/ " 7 184 "/m~0n" 8 186 6. URI Fragment Identifier Representation 188 A JSON Pointer can be represented in a URI fragment identifier by 189 encoding it into octets, using UTF-8 [RFC3629], percent-encoding 190 those characters not allowed by the fragment rule in [RFC3986]. 192 Note that a given media type needs to nominate JSON Pointer as its 193 fragment identifier syntax explicitly (usually, in its registration 194 [RFC4288]); i.e., just because a document is JSON does not imply that 195 JSON Pointer can be used as its fragment identifier syntax. In 196 particular, the fragment identifier syntax for application/json is 197 not JSON Pointer. 199 Given the same example document as above, the following URI fragment 200 identifiers evaluate to the accompanying values: 202 # // the whole document 203 #/foo ["bar", "baz"] 204 #/foo/0 "bar" 205 #/ 0 206 #/a~1b 1 207 #/c%25d 2 208 #/e%5Ef 3 209 #/g%7Ch 4 210 #/i%5Cj 5 211 #/k%22l 6 212 #/%20 7 213 #/m~0n 8 215 7. Error Handling 217 In the event of an error condition, evaluation of the JSON Pointer 218 fails to complete. 220 This includes, but is not limited to: 222 o Invalid pointer syntax 224 o A pointer that references a non-existent value 226 This specification does not define how errors are handled; an 227 application of JSON Pointer SHOULD specify the impact and handling of 228 each type of error. 230 For example, some applications might stop pointer processing upon an 231 error; others may attempt to recover from missing values by inserting 232 default ones. 234 8. IANA Considerations 236 This document has no impact upon IANA. 238 9. Security Considerations 240 A given JSON Pointer is not guaranteed to reference an actual JSON 241 value. Implementations should be aware of this and take appropriate 242 precautions. 244 Note that JSON pointers can contain the NUL (Unicode U+0000) 245 character. Care is needed not to misinterpret this character in 246 programming languages that use NUL to mark the end of a string. 248 10. Acknowledgements 250 The following individuals contributed ideas, feedback and wording to 251 this specification: 253 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 254 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 255 Reschke. 257 11. References 259 11.1. Normative References 261 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 262 Requirement Levels", BCP 14, RFC 2119, March 1997. 264 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 265 10646", STD 63, RFC 3629, November 2003. 267 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 268 Resource Identifier (URI): Generic Syntax", STD 66, 269 RFC 3986, January 2005. 271 [RFC4627] Crockford, D., "The application/json Media Type for 272 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 274 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 275 Specifications: ABNF", STD 68, RFC 5234, January 2008. 277 [Unicode] The Unicode Consortium, "The Unicode Standard, Version 278 6.0", October 2011, 279 . 281 11.2. Informative References 283 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 284 Registration Procedures", BCP 13, RFC 4288, December 2005. 286 Authors' Addresses 288 Paul C. Bryan (editor) 289 Salesforce.com 291 Phone: +1 604 783 1481 292 Email: pbryan@anode.ca 293 Kris Zyp 294 SitePen (USA) 296 Phone: +1 650 968 8787 297 Email: kris@sitepen.com 299 Mark Nottingham (editor) 300 Akamai 302 Email: mnot@mnot.net