idnits 2.17.1 draft-ietf-appsawg-json-pointer-04.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 (September 5, 2012) is 4223 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: March 9, 2013 SitePen (USA) 6 M. Nottingham, Ed. 7 September 5, 2012 9 JSON Pointer 10 draft-ietf-appsawg-json-pointer-04 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 March 9, 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 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 If the currently referenced value is a JSON array, the reference 126 token MUST contain characters that represent an unsigned base-10 127 integer value (possibly with leading zeros), and the new 128 referenced value is the array element with the zero-based index 129 identified by the token. 131 If a reference token is being evaluated against a JSON document, 132 implementations will evaluate each token against the document's 133 contents, and terminate evaluation with an error condition if it 134 fails to resolve a concrete value for any of the JSON pointer's 135 reference tokens. See Section 7 for details. 137 5. JSON String Representation 139 A JSON Pointer can be represented in a JSON string value. Per 140 [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), 141 reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be 142 escaped. 144 Note that before processing a JSON string as a JSON Pointer, 145 backslash escape sequences must be unescaped. 147 For example, given the JSON document 148 { 149 "foo": ["bar", "baz"], 150 "": 0, 151 "a/b": 1, 152 "c%d": 2, 153 "e^f": 3, 154 "g|h": 4, 155 "i\\j": 5, 156 "k\"l": 6, 157 " ": 7, 158 "m~n": 8 159 } 161 Then the following JSON strings evaluate to the accompanying values: 163 "" // the whole document 164 "/foo" ["bar", "baz"] 165 "/foo/0" "bar" 166 "/" 0 167 "/a~1b" 1 168 "/c%d" 2 169 "/e^f" 3 170 "/g|h" 4 171 "/i\\j" 5 172 "/k\"l" 6 173 "/ " 7 174 "/m~0n" 8 176 6. URI Fragment Identifier Representation 178 A JSON Pointer can be represented in a URI fragment identifier by 179 encoding it into octets, using UTF-8 [RFC3629], percent-encoding 180 those characters not allowed by the fragment rule in [RFC3986]. 182 Note that a given media type needs to nominate JSON Pointer as its 183 fragment identifier syntax explicitly (usually, in its registration 184 [RFC4288]); i.e., just because a document is JSON does not imply that 185 JSON Pointer can be used as its fragment identifier syntax. In 186 particular, the fragment identifier syntax for application/json is 187 not JSON Pointer. 189 Given the same example document as above, the following URI fragment 190 identifiers evaluate to the accompanying values: 192 # // the whole document 193 #/foo ["bar", "baz"] 194 #/foo/0 "bar" 195 #/ 0 196 #/a~1b 1 197 #/c%25d 2 198 #/e%5Ef 3 199 #/g%7Ch 4 200 #/i%5Cj 5 201 #/k%22l 6 202 #/%20 7 203 #/m~0n 8 205 7. Error Handling 207 In the event of an error condition, evaluation of the JSON Pointer 208 fails to complete. 210 This includes, but is not limited to: 212 o Invalid pointer syntax 214 o A pointer that references a non-existent value 216 This specification does not define how errors are handled; an 217 application of JSON Pointer SHOULD specify the impact and handling of 218 each type of error. 220 For example, some applications might stop pointer processing upon an 221 error; others may attempt to recover from missing values by inserting 222 default ones. 224 8. IANA Considerations 226 This document has no impact upon IANA. 228 9. Security Considerations 230 A given JSON Pointer is not guaranteed to reference an actual JSON 231 value. Implementations should be aware of this and take appropriate 232 precautions. 234 Note that JSON pointers can contain the NUL (Unicode U+0000) 235 character, which may not be representable in all programming 236 languages. 238 10. Acknowledgements 240 The following individuals contributed ideas, feedback and wording to 241 this specification: 243 Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. 244 Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian 245 Reschke. 247 11. References 249 11.1. Normative References 251 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 252 Requirement Levels", BCP 14, RFC 2119, March 1997. 254 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 255 10646", STD 63, RFC 3629, November 2003. 257 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 258 Resource Identifier (URI): Generic Syntax", STD 66, 259 RFC 3986, January 2005. 261 [RFC4627] Crockford, D., "The application/json Media Type for 262 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 264 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 265 Specifications: ABNF", STD 68, RFC 5234, January 2008. 267 [Unicode] The Unicode Consortium, "The Unicode Standard, Version 268 6.0", October 2011, 269 . 271 11.2. Informative References 273 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 274 Registration Procedures", BCP 13, RFC 4288, December 2005. 276 Authors' Addresses 278 Paul C. Bryan (editor) 279 Salesforce.com 281 Phone: +1 604 783 1481 282 Email: pbryan@anode.ca 283 Kris Zyp 284 SitePen (USA) 286 Phone: +1 650 968 8787 287 Email: kris@sitepen.com 289 Mark Nottingham (editor) 291 Email: mnot@mnot.net