idnits 2.17.1 draft-ietf-appsawg-json-pointer-05.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 (October 22, 2012) is 4204 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: April 25, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 October 22, 2012 9 JSON Pointer 10 draft-ietf-appsawg-json-pointer-05 12 Abstract 14 JSON Pointer defines a string syntax for identifying a specific value 15 within a JSON document. 17 Status of this Memo 19 This Internet-Draft is submitted in full conformance with the 20 provisions of BCP 78 and BCP 79. 22 Internet-Drafts are working documents of the Internet Engineering 23 Task Force (IETF). Note that other groups may also distribute 24 working documents as Internet-Drafts. The list of current Internet- 25 Drafts is at http://datatracker.ietf.org/drafts/current/. 27 Internet-Drafts are draft documents valid for a maximum of six months 28 and may be updated, replaced, or obsoleted by other documents at any 29 time. It is inappropriate to use Internet-Drafts as reference 30 material or to cite them other than as "work in progress." 32 This Internet-Draft will expire on April 25, 2013. 34 Copyright Notice 36 Copyright (c) 2012 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents 41 (http://trustee.ietf.org/license-info) in effect on the date of 42 publication of this document. Please review these documents 43 carefully, as they describe your rights and restrictions with respect 44 to this document. Code Components extracted from this document must 45 include Simplified BSD License text as described in Section 4.e of 46 the Trust Legal Provisions and are provided without warranty as 47 described in the Simplified BSD License. 49 Table of Contents 51 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 52 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 53 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 54 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 55 5. JSON String Representation . . . . . . . . . . . . . . . . . . 4 56 6. URI Fragment Identifier Representation . . . . . . . . . . . . 5 57 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 58 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6 59 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 6 60 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 61 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 62 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 63 11.2. Informative References . . . . . . . . . . . . . . . . . . 7 64 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 7 66 1. Introduction 68 This specification defines JSON Pointer, a string syntax for 69 identifying a specific value within a JavaScript Object Notation 70 (JSON) [RFC4627] document. It is intended to be easily expressed in 71 JSON string values as well as Uniform Resource Identifier (URI) 72 [RFC3986] fragment identifiers. 74 2. Conventions 76 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 77 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 78 document are to be interpreted as described in [RFC2119]. 80 This specification expresses normative syntax rules using Augmented 81 Backus-Naur Form (ABNF) [RFC5234] notation. 83 3. Syntax 85 A JSON Pointer is a [Unicode] string containing a sequence of zero or 86 more reference tokens, each prefixed by a '/' (%x2F) character. 88 Since the characters '~' (%x7E) and '/' (%x2F) have a special meaning 89 in JSON Pointer, they need to be encoded as '~0' and '~1' 90 respectively, when appearing in a reference token. 92 Its ABNF syntax is: 94 json-pointer = *( "/" reference-token ) 95 reference-token = *( unescaped / escaped ) 96 unescaped = %x00-2E / %x30-7D / %x7F-10FFFF 97 escaped = "~" ( "0" / "1" ) 99 It is an error condition if a JSON Pointer value does not conform to 100 this syntax (see Section 7). 102 4. Evaluation 104 Evaluation of a JSON Pointer begins with a reference to the root 105 value of a JSON document and completes with a reference to some value 106 within the document. Each reference token in the JSON Pointer is 107 sequentially evaluated. 109 Evaluation of each reference token begins by decoding any escaped 110 character sequence; this is performed by first transforming any 111 occurrence of the sequence '~1' to '/', then transforming any 112 occurrence of the sequence '~0' to '~'. 114 The reference token then modifies which value is referenced according 115 to the following scheme: 117 o If the currently referenced value is a JSON object, the new 118 referenced value is the object member with the name identified by 119 the reference token. The member name is equal to the token if it 120 has the same number of Unicode characters as token and their code 121 points are position-wise equal. If a referenced member name is 122 not unique in an object, the member that is referenced is 123 undefined, and evaluation fails (see below). 125 o If the currently referenced value is a JSON array, the reference 126 token MUST contain either: 128 * characters that represent an unsigned base-10 integer value 129 (possibly with leading zeros), making the new referenced value 130 is the array element with the zero-based index identified by 131 the token, or 133 * exactly the single character "-", making the new referenced 134 value the (non-existant) member after the last array element. 136 If a reference token is being evaluated against a JSON document, 137 implementations will evaluate each token against the document's 138 contents, and terminate evaluation with an error condition if it 139 fails to resolve a concrete value for any of the JSON pointer's 140 reference tokens. See Section 7 for details. 142 Note that the use of the "-" character to index an array will always 143 result in such an error; applications of JSON Pointer thus need to 144 specify how it is to be handled, if it is to be useful. 146 5. JSON String Representation 148 A JSON Pointer can be represented in a JSON string value. Per 149 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 150 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 151 escaped. 153 Note that before processing a JSON string as a JSON Pointer, 154 backslash escape sequences must be unescaped. 156 For example, given the JSON document 157 { 158 "foo": ["bar", "baz"], 159 "": 0, 160 "a/b": 1, 161 "c%d": 2, 162 "e^f": 3, 163 "g|h": 4, 164 "i\\j": 5, 165 "k\"l": 6, 166 " ": 7, 167 "m~n": 8 168 } 170 Then the following JSON strings evaluate to the accompanying values: 172 "" // the whole document 173 "/foo" ["bar", "baz"] 174 "/foo/0" "bar" 175 "/" 0 176 "/a~1b" 1 177 "/c%d" 2 178 "/e^f" 3 179 "/g|h" 4 180 "/i\\j" 5 181 "/k\"l" 6 182 "/ " 7 183 "/m~0n" 8 185 6. URI Fragment Identifier Representation 187 A JSON Pointer can be represented in a URI fragment identifier by 188 encoding it into octets, using UTF-8 [RFC3629], percent-encoding 189 those characters not allowed by the fragment rule in [RFC3986]. 191 Note that a given media type needs to nominate JSON Pointer as its 192 fragment identifier syntax explicitly (usually, in its registration 193 [RFC4288]); i.e., just because a document is JSON does not imply that 194 JSON Pointer can be used as its fragment identifier syntax. In 195 particular, the fragment identifier syntax for application/json is 196 not JSON Pointer. 198 Given the same example document as above, the following URI fragment 199 identifiers evaluate to the accompanying values: 201 # // the whole document 202 #/foo ["bar", "baz"] 203 #/foo/0 "bar" 204 #/ 0 205 #/a~1b 1 206 #/c%25d 2 207 #/e%5Ef 3 208 #/g%7Ch 4 209 #/i%5Cj 5 210 #/k%22l 6 211 #/%20 7 212 #/m~0n 8 214 7. Error Handling 216 In the event of an error condition, evaluation of the JSON Pointer 217 fails to complete. 219 This includes, but is not limited to: 221 o Invalid pointer syntax 223 o A pointer that references a non-existent value 225 This specification does not define how errors are handled; an 226 application of JSON Pointer SHOULD specify the impact and handling of 227 each type of error. 229 For example, some applications might stop pointer processing upon an 230 error; others may attempt to recover from missing values by inserting 231 default ones. 233 8. IANA Considerations 235 This document has no impact upon IANA. 237 9. Security Considerations 239 A given JSON Pointer is not guaranteed to reference an actual JSON 240 value. Implementations should be aware of this and take appropriate 241 precautions. 243 Note that JSON pointers can contain the NUL (Unicode U+0000) 244 character, which may not be representable in all programming 245 languages. 247 10. Acknowledgements 249 The following individuals contributed ideas, feedback and wording to 250 this specification: 252 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 253 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 254 Reschke. 256 11. References 258 11.1. Normative References 260 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 261 Requirement Levels", BCP 14, RFC 2119, March 1997. 263 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 264 10646", STD 63, RFC 3629, November 2003. 266 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 267 Resource Identifier (URI): Generic Syntax", STD 66, 268 RFC 3986, January 2005. 270 [RFC4627] Crockford, D., "The application/json Media Type for 271 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 273 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 274 Specifications: ABNF", STD 68, RFC 5234, January 2008. 276 [Unicode] The Unicode Consortium, "The Unicode Standard, Version 277 6.0", October 2011, 278 . 280 11.2. Informative References 282 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 283 Registration Procedures", BCP 13, RFC 4288, December 2005. 285 Authors' Addresses 287 Paul C. Bryan (editor) 288 Salesforce.com 290 Phone: +1 604 783 1481 291 Email: pbryan@anode.ca 292 Kris Zyp 293 SitePen (USA) 295 Phone: +1 650 968 8787 296 Email: kris@sitepen.com 298 Mark Nottingham (editor) 300 Email: mnot@mnot.net