| < draft-ietf-appsawg-json-pointer-07.txt | draft-ietf-appsawg-json-pointer-08.txt > | |||
|---|---|---|---|---|
| Applications Area Working Group P. Bryan, Ed. | Applications Area Working Group P. Bryan, Ed. | |||
| Internet-Draft Salesforce.com | Internet-Draft Salesforce.com | |||
| Intended status: Informational K. Zyp | Intended status: Standards Track K. Zyp | |||
| Expires: June 14, 2013 SitePen (USA) | Expires: July 8, 2013 SitePen (USA) | |||
| M. Nottingham, Ed. | M. Nottingham, Ed. | |||
| Akamai | Akamai | |||
| December 11, 2012 | January 4, 2013 | |||
| JSON Pointer | JavaScript Object Notation (JSON) Pointer | |||
| draft-ietf-appsawg-json-pointer-07 | draft-ietf-appsawg-json-pointer-08 | |||
| 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 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 | This Internet-Draft is submitted in full conformance with the | |||
| provisions of BCP 78 and BCP 79. | provisions of BCP 78 and BCP 79. | |||
| Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
| Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
| working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
| Drafts is at http://datatracker.ietf.org/drafts/current/. | Drafts is at http://datatracker.ietf.org/drafts/current/. | |||
| Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
| and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
| time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
| material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
| This Internet-Draft will expire on June 14, 2013. | This Internet-Draft will expire on July 8, 2013. | |||
| Copyright Notice | Copyright Notice | |||
| Copyright (c) 2012 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 . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 5. JSON String Representation . . . . . . . . . . . . . . . . . . 4 | 5. JSON String Representation . . . . . . . . . . . . . . . . . . 5 | |||
| 6. URI Fragment Identifier Representation . . . . . . . . . . . . 5 | 6. URI Fragment Identifier Representation . . . . . . . . . . . . 6 | |||
| 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 | 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 | |||
| 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6 | 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7 | |||
| 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 | 9. Security Considerations . . . . . . . . . . . . . . . . . . . . 7 | |||
| 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 | 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
| 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 | 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
| 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 | 11.1. Normative References . . . . . . . . . . . . . . . . . . . 7 | |||
| 11.2. Informative References . . . . . . . . . . . . . . . . . . 7 | 11.2. Informative References . . . . . . . . . . . . . . . . . . 8 | |||
| Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 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) [RFC4627] document. It is intended to be easily expressed in | |||
| JSON string values as well as Uniform Resource Identifier (URI) | JSON string values as well as Uniform Resource Identifier (URI) | |||
| [RFC3986] fragment identifiers. | [RFC3986] fragment identifiers. | |||
| skipping to change at page 3, line 45 ¶ | skipping to change at page 3, line 45 ¶ | |||
| 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. | ||||
| 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. By performing the substitutions in this | sequentially evaluated. | |||
| order, an implementation avoids the error of turning '~01' first into | ||||
| '~1' and then into '/', which would be incorrect (the string '~01' | ||||
| correctly becomes '~1' after transformation). | ||||
| 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 '/', then transforming any | |||
| occurrence of the sequence '~0' to '~'. | occurrence of the sequence '~0' to '~'. By performing the | |||
| substitutions in this order, an implementation avoids the error of | ||||
| turning '~01' first into '~1' and then into '/', which would be | ||||
| incorrect (the string '~01' correctly becomes '~1' after | ||||
| 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 token and their code | has the same number of Unicode characters as token and their code | |||
| points are position-wise equal. No Unicode character | points are position-wise 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 that represent an unsigned base-10 integer value | * characters comprised of digits (see ABNF below; note that | |||
| (possibly with leading zeros), making the new referenced value | leading zeros are not allowed) that represent an unsigned | |||
| the array element with the zero-based index identified by the | base-10 integer value, making the new referenced value 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 (non-existant) member after the last array element. | |||
| If a reference token is being evaluated against a JSON document, | The ABNF syntax for array indices is: | |||
| implementations will evaluate each token against the document's | ||||
| contents, and terminate evaluation with an error condition if it | array-index = %x30 / ( %x31-39 *(%x30-39) ) | |||
| fails to resolve a concrete value for any of the JSON pointer's | ; "0", or digits without a leading "0" | |||
| reference tokens. See Section 7 for details. | ||||
| Implementations will evaluate each reference 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. For example, if an array is referenced with a non- | ||||
| numeric token, it will fail. 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; applications of JSON Pointer thus need to | result in such an error; applications of JSON Pointer thus need to | |||
| specify how it is to be handled, if it is to be useful. | specify how it is to be handled, if it is to be useful. | |||
| 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 | |||
| skipping to change at page 5, line 27 ¶ | skipping to change at page 5, line 36 ¶ | |||
| "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: | Then 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 | encoding it into octets using UTF-8 [RFC3629], percent-encoding those | |||
| those characters not allowed by the fragment rule in [RFC3986]. | characters not allowed by the fragment rule in [RFC3986]. | |||
| Note that a given media type needs to nominate 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 | [RFC4288]); i.e., just because a document is JSON does not imply that | |||
| JSON Pointer can be used as its fragment identifier syntax. In | 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 | |||
| #/a~1b 1 | #/a~1b 1 | |||
| #/c%25d 2 | #/c%25d 2 | |||
| #/e%5Ef 3 | #/e%5Ef 3 | |||
| #/g%7Ch 4 | #/g%7Ch 4 | |||
| #/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: | This includes, but is not limited to: | |||
| o Invalid pointer syntax | o Invalid pointer syntax | |||
| End of changes. 19 change blocks. | ||||
| 42 lines changed or deleted | 51 lines changed or added | |||
This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ | ||||