Applications Area Working Group P. Bryan, Ed. Internet-Draft ForgeRock Intended status: Informational K. Zyp Expires: February 12, 2013 SitePen (USA) M. Nottingham, Ed. Rackspace August 11, 2012 JSON Pointer draft-ietf-appsawg-json-pointer-03 Abstract JSON Pointer defines a string syntax for identifying a specific value within a JSON document. Status of this Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on February 12, 2013. Copyright Notice Copyright (c) 2012 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Bryan, et al. Expires February 12, 2013 [Page 1]

Internet-Draft JSON Pointer August 2012 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5. JSON String Representation . . . . . . . . . . . . . . . . . . 4 6. URI Fragment Identifier Representation . . . . . . . . . . . . 5 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 6 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 6 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 11.2. Informative References . . . . . . . . . . . . . . . . . . 7 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 7 Bryan, et al. Expires February 12, 2013 [Page 2]

Internet-Draft JSON Pointer August 2012 1 . Introduction RFC4627] document. It is intended to be easily expressed in JSON string values as well as Uniform Resource Identifier (URI) [RFC3986] fragment identifiers. 2 . Conventions RFC2119]. This specification expresses normative syntax rules using Augmented Backus-Naur Form [RFC5234] (ABNF) notation. 3 . Syntax Unicode] string containing a sequence of zero or more reference tokens, each prefixed by a '/' (%x2F) character. If a reference token contains '~' (%x7E) or '/' (%x2F) characters, they MUST be encoded as '~0' and '~1' respectively. Its ABNF syntax is: json-pointer = *( "/" reference-token ) reference-token = *( unescaped / escaped ) unescaped = %x00-2E / %x30-7D / %x7F-10FFFF escaped = "~" ( "0" / "1" ) It is an error condition if a JSON Pointer value does not conform to this syntax (see Section 7). 4 . Evaluation Bryan, et al. Expires February 12, 2013 [Page 3]

Internet-Draft JSON Pointer August 2012 occurrence of the sequence '~0' to '~'. The reference token then modifies which value is referenced according to the following scheme: If the currently referenced value is a JSON object, the new referenced value is the object member with the name (after unescaping any backslash escape sequences that can occur in a JSON string) identified by the reference token. The member name is equal to the token if it has the same number of Unicode characters as token and their code points are position-wise equal. If a referenced member name is not unique in an object, the member that is referenced is undefined, and evaluation fails (see below). If the currently referenced value is a JSON array, the reference token MUST contain characters that represent an unsigned base-10 integer value (possibly with leading zeros), and the new referenced value is the array element with the zero-based index identified by the token. If a reference token is being evaluated against a JSON document, implementations will evaluate each token against the document's contents, and terminate evaluation with an error condition if it fails to resolve a concrete value for any of the JSON pointer's reference tokens. See Section 7 for details. 5 . JSON String Representation [RFC4627], section 2.5, all instances of quotation mark '"' (%x22), reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be escaped. For example, given the JSON document { "foo": ["bar", "baz"], "": 0, "a/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 Bryan, et al. Expires February 12, 2013 [Page 4]

Internet-Draft JSON Pointer August 2012 } Then the following JSON strings evaluate to the accompanying values: "" // the whole document "/foo" ["bar", "baz"] "/foo/0" "bar" "/" 0 "/a~1b" 1 "/c%d" 2 "/e^f" 3 "/g|h" 4 "/i\\j" 5 "/k\"l" 6 "/ " 7 "/m~0n" 8 6 . URI Fragment Identifier Representation RFC3629], percent-encoding those characters not allowed by the fragment rule in [RFC3986]. Note that a given media type needs to nominate JSON Pointer as its fragment identifier syntax explicitly (usually, in its registration [RFC4288]); i.e., just because a document is JSON does not imply that JSON Pointer can be used as its fragment identifier syntax. Given the same example document as above, the following URI fragment identifiers evaluate to the accompanying values: # // the whole document #/foo ["bar", "baz"] #/foo/0 "bar" #/ 0 #/a~1b 1 #/c%25d 2 #/e%5Ef 3 #/g%7Ch 4 #/i%5Cj 5 #/k%22l 6 #/%20 7 #/m~0n 8 Bryan, et al. Expires February 12, 2013 [Page 5]

Internet-Draft JSON Pointer August 2012 7 . Error Handling 8 . IANA Considerations 9 . Security Considerations 10 . Acknowledgements 11 . References Bryan, et al. Expires February 12, 2013 [Page 6]

Internet-Draft JSON Pointer August 2012 Mark Nottingham (editor) Rackspace Email: mnot@mnot.net Bryan, et al. Expires February 12, 2013 [Page 8]