draft-ietf-appsawg-json-pointer-09.txt   rfc6901.txt 
Applications Area Working Group P. Bryan, Ed. Internet Engineering Task Force (IETF) P. Bryan, Ed.
Internet-Draft Salesforce.com Request for Comments: 6901 Salesforce.com
Intended status: Standards Track K. Zyp Category: Standards Track K. Zyp
Expires: July 26, 2013 SitePen (USA) ISSN: 2070-1721 SitePen (USA)
M. Nottingham, Ed. M. Nottingham, Ed.
Akamai Akamai
January 22, 2013 April 2013
JavaScript Object Notation (JSON) Pointer JavaScript Object Notation (JSON) Pointer
draft-ietf-appsawg-json-pointer-09
Abstract Abstract
JSON Pointer defines a string syntax for identifying a specific value JSON Pointer defines a string syntax for identifying a specific value
within a JavaScript Object Notation (JSON) document. within a JavaScript Object Notation (JSON) document.
Status of this Memo 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 This is an Internet Standards Track document.
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 This document is a product of the Internet Engineering Task Force
and may be updated, replaced, or obsoleted by other documents at any (IETF). It represents the consensus of the IETF community. It has
time. It is inappropriate to use Internet-Drafts as reference received public review and has been approved for publication by the
material or to cite them other than as "work in progress." Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
This Internet-Draft will expire on July 26, 2013. Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc6901.
Copyright Notice Copyright Notice
Copyright (c) 2013 IETF Trust and the persons identified as the Copyright (c) 2013 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5. JSON String Representation . . . . . . . . . . . . . . . . . . 5 5. JSON String Representation . . . . . . . . . . . . . . . . . . 4
6. URI Fragment Identifier Representation . . . . . . . . . . . . 6 6. URI Fragment Identifier Representation . . . . . . . . . . . . 5
7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 7 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7 8. Security Considerations . . . . . . . . . . . . . . . . . . . . 6
9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7
10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7
11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 8 10.1. Normative References . . . . . . . . . . . . . . . . . . . 7
11.1. Normative References . . . . . . . . . . . . . . . . . . . 8 10.2. Informative References . . . . . . . . . . . . . . . . . . 7
11.2. Informative References . . . . . . . . . . . . . . . . . . 8
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 8
1. Introduction 1. Introduction
This specification defines JSON Pointer, a string syntax for This specification defines JSON Pointer, a string syntax for
identifying a specific value within a JavaScript Object Notation identifying a specific value within a JavaScript Object Notation
(JSON) [RFC4627] document. It is intended to be easily expressed in (JSON) document [RFC4627]. JSON Pointer is intended to be easily
JSON string values as well as Uniform Resource Identifier (URI) expressed in JSON string values as well as Uniform Resource
[RFC3986] fragment identifiers. Identifier (URI) [RFC3986] fragment identifiers.
2. Conventions 2. Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119]. document are to be interpreted as described in [RFC2119].
This specification expresses normative syntax rules using Augmented This specification expresses normative syntax rules using Augmented
Backus-Naur Form (ABNF) [RFC5234] notation. Backus-Naur Form (ABNF) [RFC5234] notation.
skipping to change at page 3, line 35 skipping to change at page 3, line 7
containing a sequence of zero or more reference tokens, each prefixed containing a sequence of zero or more reference tokens, each prefixed
by a '/' (%x2F) character. by a '/' (%x2F) character.
Because the characters '~' (%x7E) and '/' (%x2F) have special Because the characters '~' (%x7E) and '/' (%x2F) have special
meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/' meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/'
needs to be encoded as '~1' when these characters appear in a needs to be encoded as '~1' when these characters appear in a
reference token. reference token.
The ABNF syntax of a JSON Pointer is: The ABNF syntax of a JSON Pointer is:
json-pointer = *( "/" reference-token ) json-pointer = *( "/" reference-token )
reference-token = *( unescaped / escaped ) reference-token = *( unescaped / escaped )
unescaped = %x00-2E / %x30-7D / %x7F-10FFFF unescaped = %x00-2E / %x30-7D / %x7F-10FFFF
; %x2F ('/') and %x7E ('~') are excluded from 'unescaped' ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'
escaped = "~" ( "0" / "1" ) escaped = "~" ( "0" / "1" )
; representing '~' and '/', respectively ; representing '~' and '/', respectively
It is an error condition if a JSON Pointer value does not conform to It is an error condition if a JSON Pointer value does not conform to
this syntax (see Section 7). this syntax (see Section 7).
Note that JSON Pointers are specified in characters, not as bytes. Note that JSON Pointers are specified in characters, not as bytes.
4. Evaluation 4. Evaluation
Evaluation of a JSON Pointer begins with a reference to the root Evaluation of a JSON Pointer begins with a reference to the root
value of a JSON document and completes with a reference to some value value of a JSON document and completes with a reference to some value
within the document. Each reference token in the JSON Pointer is within the document. Each reference token in the JSON Pointer is
sequentially evaluated. evaluated sequentially.
Evaluation of each reference token begins by decoding any escaped Evaluation of each reference token begins by decoding any escaped
character sequence; this is performed by first transforming any character sequence. This is performed by first transforming any
occurrence of the sequence '~1' to '/', then transforming any occurrence of the sequence '~1' to '/', and then transforming any
occurrence of the sequence '~0' to '~'. By performing the occurrence of the sequence '~0' to '~'. By performing the
substitutions in this order, an implementation avoids the error of substitutions in this order, an implementation avoids the error of
turning '~01' first into '~1' and then into '/', which would be turning '~01' first into '~1' and then into '/', which would be
incorrect (the string '~01' correctly becomes '~1' after incorrect (the string '~01' correctly becomes '~1' after
transformation). transformation).
The reference token then modifies which value is referenced according The reference token then modifies which value is referenced according
to the following scheme: to the following scheme:
o If the currently referenced value is a JSON object, the new o If the currently referenced value is a JSON object, the new
referenced value is the object member with the name identified by referenced value is the object member with the name identified by
the reference token. The member name is equal to the token if it the reference token. The member name is equal to the token if it
has the same number of Unicode characters as the token and their has the same number of Unicode characters as the token and their
code points are position-wise equal. No Unicode character code points are byte-by-byte equal. No Unicode character
normalization is performed. If a referenced member name is not normalization is performed. If a referenced member name is not
unique in an object, the member that is referenced is undefined, unique in an object, the member that is referenced is undefined,
and evaluation fails (see below). and evaluation fails (see below).
o If the currently referenced value is a JSON array, the reference o If the currently referenced value is a JSON array, the reference
token MUST contain either: token MUST contain either:
* characters comprised of digits (see ABNF below; note that * characters comprised of digits (see ABNF below; note that
leading zeros are not allowed) that represent an unsigned leading zeros are not allowed) that represent an unsigned
base-10 integer value, making the new referenced value the base-10 integer value, making the new referenced value the
array element with the zero-based index identified by the array element with the zero-based index identified by the
token, or token, or
* exactly the single character "-", making the new referenced * exactly the single character "-", making the new referenced
value the (non-existant) member after the last array element. value the (nonexistent) member after the last array element.
The ABNF syntax for array indices is: The ABNF syntax for array indices is:
array-index = %x30 / ( %x31-39 *(%x30-39) ) array-index = %x30 / ( %x31-39 *(%x30-39) )
; "0", or digits without a leading "0" ; "0", or digits without a leading "0"
Implementations will evaluate each reference token against the Implementations will evaluate each reference token against the
document's contents, and will raise an error condition if it fails to document's contents and will raise an error condition if it fails to
resolve a concrete value for any of the JSON pointer's reference resolve a concrete value for any of the JSON pointer's reference
tokens. For example, if an array is referenced with a non-numeric tokens. For example, if an array is referenced with a non-numeric
token, an error condition will be raised. See Section 7 for details. token, an error condition will be raised. See Section 7 for details.
Note that the use of the "-" character to index an array will always Note that the use of the "-" character to index an array will always
result in such an error condition because by definition it refers to result in such an error condition because by definition it refers to
a non-existent array element. Applications of JSON Pointer thus need a nonexistent array element. Thus, applications of JSON Pointer need
to specify how it is to be handled, if it is to be useful. to specify how that character is to be handled, if it is to be
useful.
Any error condition that does not have a specific action defined for Any error condition for which a specific action is not defined by the
it by the JSON Pointer application results in termination of JSON Pointer application results in termination of evaluation.
evaluation.
5. JSON String Representation 5. JSON String Representation
A JSON Pointer can be represented in a JSON string value. Per A JSON Pointer can be represented in a JSON string value. Per
[RFC4627], Section 2.5, all instances of quotation mark '"' (%x22), [RFC4627], Section 2.5, all instances of quotation mark '"' (%x22),
reverse solidus '\' (%x5C) and control (%x00-1F) characters MUST be reverse solidus '\' (%x5C), and control (%x00-1F) characters MUST be
escaped. escaped.
Note that before processing a JSON string as a JSON Pointer, Note that before processing a JSON string as a JSON Pointer,
backslash escape sequences must be unescaped. backslash escape sequences must be unescaped.
For example, given the JSON document For example, given the JSON document
{ {
"foo": ["bar", "baz"], "foo": ["bar", "baz"],
"": 0, "": 0,
"a/b": 1, "a/b": 1,
"c%d": 2, "c%d": 2,
"e^f": 3, "e^f": 3,
"g|h": 4, "g|h": 4,
"i\\j": 5, "i\\j": 5,
"k\"l": 6, "k\"l": 6,
" ": 7, " ": 7,
"m~n": 8 "m~n": 8
} }
Then the following JSON strings evaluate to the accompanying values: The following JSON strings evaluate to the accompanying values:
"" // the whole document "" // the whole document
"/foo" ["bar", "baz"] "/foo" ["bar", "baz"]
"/foo/0" "bar" "/foo/0" "bar"
"/" 0 "/" 0
"/a~1b" 1 "/a~1b" 1
"/c%d" 2 "/c%d" 2
"/e^f" 3 "/e^f" 3
"/g|h" 4 "/g|h" 4
"/i\\j" 5 "/i\\j" 5
"/k\"l" 6 "/k\"l" 6
"/ " 7 "/ " 7
"/m~0n" 8 "/m~0n" 8
6. URI Fragment Identifier Representation 6. URI Fragment Identifier Representation
A JSON Pointer can be represented in a URI fragment identifier by A JSON Pointer can be represented in a URI fragment identifier by
encoding it into octets using UTF-8 [RFC3629], percent-encoding those encoding it into octets using UTF-8 [RFC3629], while percent-encoding
characters not allowed by the fragment rule in [RFC3986]. those characters not allowed by the fragment rule in [RFC3986].
Note that a given media type needs to specify JSON Pointer as its Note that a given media type needs to specify JSON Pointer as its
fragment identifier syntax explicitly (usually, in its registration fragment identifier syntax explicitly (usually, in its registration
[RFC4288]); i.e., just because a document is JSON does not imply that [RFC6838]). That is, just because a document is JSON does not imply
JSON Pointer can be used as its fragment identifier syntax. In that JSON Pointer can be used as its fragment identifier syntax. In
particular, the fragment identifier syntax for application/json is particular, the fragment identifier syntax for application/json is
not JSON Pointer. not JSON Pointer.
Given the same example document as above, the following URI fragment Given the same example document as above, the following URI fragment
identifiers evaluate to the accompanying values: identifiers evaluate to the accompanying values:
# // the whole document # // the whole document
#/foo ["bar", "baz"] #/foo ["bar", "baz"]
#/foo/0 "bar" #/foo/0 "bar"
#/ 0 #/ 0
skipping to change at page 7, line 10 skipping to change at page 6, line 26
#/i%5Cj 5 #/i%5Cj 5
#/k%22l 6 #/k%22l 6
#/%20 7 #/%20 7
#/m~0n 8 #/m~0n 8
7. Error Handling 7. Error Handling
In the event of an error condition, evaluation of the JSON Pointer In the event of an error condition, evaluation of the JSON Pointer
fails to complete. fails to complete.
This includes, but is not limited to: Error conditions include, but are not limited to:
o Invalid pointer syntax o Invalid pointer syntax
o A pointer that references a non-existent value o A pointer that references a nonexistent value
This specification does not define how errors are handled; an This specification does not define how errors are handled. An
application of JSON Pointer SHOULD specify the impact and handling of application of JSON Pointer SHOULD specify the impact and handling of
each type of error. each type of error.
For example, some applications might stop pointer processing upon an For example, some applications might stop pointer processing upon an
error; others may attempt to recover from missing values by inserting error, while others may attempt to recover from missing values by
default ones. inserting default ones.
8. IANA Considerations
This document has no impact upon IANA.
9. Security Considerations 8. Security Considerations
A given JSON Pointer is not guaranteed to reference an actual JSON A given JSON Pointer is not guaranteed to reference an actual JSON
value. Therefore, applications using JSON Pointer should anticipate value. Therefore, applications using JSON Pointer should anticipate
this by defining how a pointer that does not resolve ought to be this situation by defining how a pointer that does not resolve ought
handled. to be handled.
Note that JSON pointers can contain the NUL (Unicode U+0000) Note that JSON pointers can contain the NUL (Unicode U+0000)
character. Care is needed not to misinterpret this character in character. Care is needed not to misinterpret this character in
programming languages that use NUL to mark the end of a string. programming languages that use NUL to mark the end of a string.
10. Acknowledgements 9. Acknowledgements
The following individuals contributed ideas, feedback and wording to The following individuals contributed ideas, feedback, and wording to
this specification: this specification:
Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J. Mike Acar, Carsten Bormann, Tim Bray, Jacob Davies, Martin J.
Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, Julian Duerst, Bjoern Hoehrmann, James H. Manger, Drew Perttula, and
Reschke. Julian Reschke.
11. References 10. References
11.1. Normative References
10.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997. Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
10646", STD 63, RFC 3629, November 2003. 10646", STD 63, RFC 3629, November 2003.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66, Resource Identifier (URI): Generic Syntax", STD 66,
RFC 3986, January 2005. RFC 3986, January 2005.
[RFC4627] Crockford, D., "The application/json Media Type for [RFC4627] Crockford, D., "The application/json Media Type for
JavaScript Object Notation (JSON)", RFC 4627, July 2006. JavaScript Object Notation (JSON)", RFC 4627, July 2006.
[RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234, January 2008. Specifications: ABNF", STD 68, RFC 5234, January 2008.
11.2. Informative References 10.2. Informative References
[RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type
Registration Procedures", BCP 13, RFC 4288, December 2005. Specifications and Registration Procedures", BCP 13,
RFC 6838, January 2013.
Authors' Addresses Authors' Addresses
Paul C. Bryan (editor) Paul C. Bryan (editor)
Salesforce.com Salesforce.com
Phone: +1 604 783 1481 Phone: +1 604 783 1481
Email: pbryan@anode.ca EMail: pbryan@anode.ca
Kris Zyp Kris Zyp
SitePen (USA) SitePen (USA)
Phone: +1 650 968 8787 Phone: +1 650 968 8787
Email: kris@sitepen.com EMail: kris@sitepen.com
Mark Nottingham (editor) Mark Nottingham (editor)
Akamai Akamai
Email: mnot@mnot.net EMail: mnot@mnot.net
 End of changes. 37 change blocks. 
81 lines changed or deleted 73 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/