| < draft-ietf-appsawg-json-patch-00.txt | draft-ietf-appsawg-json-patch-01.txt > | |||
|---|---|---|---|---|
| Applications Area Working Group P. Bryan, Ed. | Applications Area Working Group P. Bryan, Ed. | |||
| Internet-Draft ForgeRock US, Inc. | Internet-Draft ForgeRock | |||
| Intended status: Standards Track January 3, 2012 | Intended status: Informational March 9, 2012 | |||
| Expires: July 6, 2012 | Expires: September 10, 2012 | |||
| JSON Patch | JSON Patch | |||
| draft-ietf-appsawg-json-patch-00 | draft-ietf-appsawg-json-patch-01 | |||
| Abstract | Abstract | |||
| JSON Patch defines the media type "application/json-patch", a JSON | JSON Patch defines the media type "application/json-patch", a JSON | |||
| document structure for expressing a sequence of operations to apply | document structure for expressing a sequence of operations to apply | |||
| to a JSON document. | to a 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 | |||
| skipping to change at page 1, line 32 ¶ | skipping to change at page 1, line 32 ¶ | |||
| 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 July 6, 2012. | This Internet-Draft will expire on September 10, 2012. | |||
| Copyright Notice | Copyright Notice | |||
| Copyright (c) 2012 IETF Trust and the persons identified as the | Copyright (c) 2012 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 | |||
| skipping to change at page 2, line 15 ¶ | skipping to change at page 2, line 15 ¶ | |||
| Table of Contents | Table of Contents | |||
| 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 3. Document Structure . . . . . . . . . . . . . . . . . . . . . . 3 | 3. Document Structure . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 4. Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | 4. Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 4.1. add . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 4.1. add . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
| 4.2. remove . . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 4.2. remove . . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
| 4.3. replace . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 4.3. replace . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
| 4.4. move . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 | 4.4. move . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 | |||
| 4.5. test . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 | 4.5. copy . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 | |||
| 4.6. test . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 | ||||
| 5. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 | 5. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 | |||
| 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6 | 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6 | |||
| 7. Security Considerations . . . . . . . . . . . . . . . . . . . 7 | 7. Security Considerations . . . . . . . . . . . . . . . . . . . 7 | |||
| 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 | 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
| 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 7 | 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 8 | |||
| 9.1. Normative References . . . . . . . . . . . . . . . . . . . 7 | 9.1. Normative References . . . . . . . . . . . . . . . . . . . 8 | |||
| 9.2. Informative References . . . . . . . . . . . . . . . . . . 7 | 9.2. Informative References . . . . . . . . . . . . . . . . . . 8 | |||
| Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 8 | Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 8 | |||
| A.1. Adding an Object Member . . . . . . . . . . . . . . . . . 8 | A.1. Adding an Object Member . . . . . . . . . . . . . . . . . 8 | |||
| A.2. Adding an Array Element . . . . . . . . . . . . . . . . . 8 | A.2. Adding an Array Element . . . . . . . . . . . . . . . . . 9 | |||
| A.3. Removing an Object Member . . . . . . . . . . . . . . . . 9 | A.3. Removing an Object Member . . . . . . . . . . . . . . . . 9 | |||
| A.4. Removing an Array Element . . . . . . . . . . . . . . . . 9 | A.4. Removing an Array Element . . . . . . . . . . . . . . . . 10 | |||
| A.5. Replacing a Value . . . . . . . . . . . . . . . . . . . . 10 | A.5. Replacing a Value . . . . . . . . . . . . . . . . . . . . 10 | |||
| A.6. Moving a Value . . . . . . . . . . . . . . . . . . . . . . 10 | A.6. Moving a Value . . . . . . . . . . . . . . . . . . . . . . 11 | |||
| A.7. Moving an Array Element . . . . . . . . . . . . . . . . . 11 | A.7. Moving an Array Element . . . . . . . . . . . . . . . . . 11 | |||
| A.8. Testing a Value: Success . . . . . . . . . . . . . . . . . 11 | A.8. Testing a Value: Success . . . . . . . . . . . . . . . . . 12 | |||
| A.9. Testing a Value: Error . . . . . . . . . . . . . . . . . . 12 | A.9. Testing a Value: Error . . . . . . . . . . . . . . . . . . 12 | |||
| Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 12 | Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 12 | |||
| 1. Introduction | 1. Introduction | |||
| JavaScript Object Notation (JSON) [RFC4627] is a common format for | JavaScript Object Notation (JSON) [RFC4627] is a common format for | |||
| the exchange and storage of structured data. HTTP PATCH [RFC5789] | the exchange and storage of structured data. HTTP PATCH [RFC5789] | |||
| extends the Hypertext Transfer Protocol (HTTP) [RFC2616] with a | extends the Hypertext Transfer Protocol (HTTP) [RFC2616] with a | |||
| method to perform partial modifications to resources. | method to perform partial modifications to resources. | |||
| skipping to change at page 3, line 34 ¶ | skipping to change at page 3, line 34 ¶ | |||
| A JSON Patch document contains a JSON array of objects. Each object | A JSON Patch document contains a JSON array of objects. Each object | |||
| contains a single operation to apply to the target JSON document. | contains a single operation to apply to the target JSON document. | |||
| An example JSON Patch document: | An example JSON Patch document: | |||
| [ | [ | |||
| { "test": "/a/b/c", "value": "foo" }, | { "test": "/a/b/c", "value": "foo" }, | |||
| { "remove": "/a/b/c" }, | { "remove": "/a/b/c" }, | |||
| { "add": "/a/b/c", "value": [ "foo", "bar" ] }, | { "add": "/a/b/c", "value": [ "foo", "bar" ] }, | |||
| { "replace": "/a/b/c", "value": 42 }, | { "replace": "/a/b/c", "value": 42 }, | |||
| { "move": "/a/b/c", "to": "/a/b/d" } | { "move": "/a/b/c", "to": "/a/b/d" }, | |||
| { "copy": "/a/b/c", "to": "/a/b/e" } | ||||
| ] | ] | |||
| Evaluation of a JSON Patch document begins with a target JSON | Evaluation of a JSON Patch document begins with a target JSON | |||
| document. Operations are applied sequentially in the order they | document. Operations are applied sequentially in the order they | |||
| appear in the array. Each operation in the sequence is applied to | appear in the array. Each operation in the sequence is applied to | |||
| the target document; the resulting document becomes the target of the | the target document; the resulting document becomes the target of the | |||
| next operation. Evaluation continues until all operations are | next operation. Evaluation continues until all operations are | |||
| successfully applied or an error condition is encountered. | successfully applied or an error condition is encountered. | |||
| 4. Operations | 4. Operations | |||
| The operation to apply is expressed in a member of the operation | The operation to perform is expressed in a member of the operation | |||
| object. The name of the operation member is one of: "add", "remove", | object. The name of the operation member is one of: "add", "remove", | |||
| "replace", "move" or "test". The member value is a string containing | "replace", "move", "copy" or "test". The member value is a string | |||
| a [JSON Pointer], which references the location within the target | containing a [JSON-Pointer] value, which references the location | |||
| document to apply the operation. It is an error condition if an | within the target document to perform the operation. It is an error | |||
| operation object contains no recognized operation member or more than | condition if an operation object contains no recognized operation | |||
| one operation member. | member or more than one operation member. | |||
| 4.1. add | 4.1. add | |||
| The "add" operation adds a new value at the specified location in the | The "add" operation adds a new value at the specified location in the | |||
| target document. The location must reference one of: the root of the | target document. The location must reference one of: the root of the | |||
| target document, a member to add to an existing object, or an element | target document, a member to add to an existing object, or an element | |||
| to add to an existing array. The operation object contains a "value" | to add to an existing array. The operation object contains a "value" | |||
| member, which specifies the value to be added. | member, which specifies the value to be added. | |||
| Example: | Example: | |||
| skipping to change at page 5, line 22 ¶ | skipping to change at page 5, line 22 ¶ | |||
| It is an error condition if a value at the specified location does | It is an error condition if a value at the specified location does | |||
| not exist. | not exist. | |||
| 4.4. move | 4.4. move | |||
| The "move" operation removes the value at one location and adds it to | The "move" operation removes the value at one location and adds it to | |||
| another location in the target document. | another location in the target document. | |||
| The operation object contains a "to" member, a string containing a | The operation object contains a "to" member, a string containing a | |||
| JSON Pointer which references the location in the target document to | JSON Pointer value, which references the location in the target | |||
| add the value to. This location must reference one of: the member to | document to add the value to. This location must reference one of: | |||
| add to an existing object, or an element to add to an existing array. | the member to add to an existing object, or an element to add to an | |||
| existing array. | ||||
| Example: | Example: | |||
| { "move": "/a/b/c", "to": "/a/b/d" } | { "move": "/a/b/c", "to": "/a/b/d" } | |||
| This operation is functionally identical to expressing a "remove" | This operation is functionally identical to expressing a "remove" | |||
| operation, followed immediately by an "add" operation at the new | operation, followed immediately by an "add" operation at the new | |||
| location with the value that was just removed. | location with the value that was just removed. Moving a value to its | |||
| current location can be safely ignored. | ||||
| If the location in the "to" member references a member of an existing | If the location in the "to" member references a member of an existing | |||
| object in the target document, it is an error condition if a value at | object in the target document, it is an error condition if a value at | |||
| the specified location already exists. | the specified location already exists. | |||
| If the location in the "to" member references an element of an | If the location in the "to" member references an element of an | |||
| existing array, any elements at or above the specified index are | existing array, any elements at or above the specified index are | |||
| shifted one position to the right. It is an error condition if the | shifted one position to the right. It is an error condition if the | |||
| specified index is greater than the number of elements in the array. | specified index is greater than the number of elements in the array. | |||
| 4.5. test | 4.5. copy | |||
| The "copy" operation copies the value at one location to another | ||||
| location in the target document. | ||||
| The operation object contains a "to" member, a string containing a | ||||
| JSON Pointer value, which references the location in the target | ||||
| document to add the value to. This location must reference one of: | ||||
| the member to add to an existing object, or an element to add to an | ||||
| existing array. | ||||
| Example: | ||||
| { "copy": "/a/b/c", "to": "/a/b/e" } | ||||
| If the location in the "to" member references a member of an existing | ||||
| object in the target document, it is an error condition if a value at | ||||
| the specified location already exists. | ||||
| If the location in the "to" member references an element of an | ||||
| existing array, any elements at or above the specified index are | ||||
| shifted one position to the right. It is an error condition if the | ||||
| specified index is greater than the number of elements in the array. | ||||
| 4.6. test | ||||
| The "test" operation tests that a value at the specified location in | The "test" operation tests that a value at the specified location in | |||
| the target document is equal to a specified value. The operation | the target document is equal to a specified value. The operation | |||
| object contains a "value" member, which specifies the value to test | object contains a "value" member, which specifies the value to test | |||
| for. | for. If values are or contain objects or arrays, they must be | |||
| identical (i.e. same order of elements, with the same values). | ||||
| Example: | Example: | |||
| { "test": "/a/b/c", "value": "foo" } | { "test": "/a/b/c", "value": "foo" } | |||
| It is an error condition if the value at the specified location is | It is an error condition if the value at the specified location is | |||
| not equal to the specified value. | not equal to the specified value. | |||
| 5. Error Handling | 5. Error Handling | |||
| If an error condition occurs, evaluation of the JSON Patch document | If an error condition occurs, evaluation of the JSON Patch document | |||
| SHOULD terminate and application of the entire patch document SHALL | SHOULD terminate and application of the entire patch document SHALL | |||
| NOT be deemed successful. | NOT be deemed successful. | |||
| 6. IANA Considerations | 6. IANA Considerations | |||
| skipping to change at page 6, line 19 ¶ | skipping to change at page 7, line 4 ¶ | |||
| If an error condition occurs, evaluation of the JSON Patch document | If an error condition occurs, evaluation of the JSON Patch document | |||
| SHOULD terminate and application of the entire patch document SHALL | SHOULD terminate and application of the entire patch document SHALL | |||
| NOT be deemed successful. | NOT be deemed successful. | |||
| 6. IANA Considerations | 6. IANA Considerations | |||
| The Internet media type for a JSON Patch document is application/ | The Internet media type for a JSON Patch document is application/ | |||
| json-patch. | json-patch. | |||
| Type name: application | Type name: application | |||
| Subtype name: json-patch | Subtype name: json-patch | |||
| Required parameters: none | Required parameters: none | |||
| Optional parameters: none | Optional parameters: none | |||
| Encoding considerations: binary | Encoding considerations: binary | |||
| Security considerations: | Security considerations: | |||
| See Security Considerations in section 7. | See Security Considerations in section 7. | |||
| Interoperability considerations: N/A | Interoperability considerations: N/A | |||
| Published specification: | Published specification: | |||
| draft-ietf-appsawg-json-patch-00 | [this memo] | |||
| Applications that use this media type: | Applications that use this media type: | |||
| Applications that manipulate JSON documents. | Applications that manipulate JSON documents. | |||
| Additional information: | Additional information: | |||
| Magic number(s): N/A | Magic number(s): N/A | |||
| File extension(s): .json-patch | File extension(s): .json-patch | |||
| Macintosh file type code(s): TEXT | Macintosh file type code(s): TEXT | |||
| Person & email address to contact for further information: | Person & email address to contact for further information: | |||
| Paul C. Bryan <paul.bryan@forgerock.com> | Paul C. Bryan <pbryan@anode.ca> | |||
| Intended usage: COMMON | Intended usage: COMMON | |||
| Restrictions on usage: none | Restrictions on usage: none | |||
| Author: Paul C. Bryan <paul.bryan@forgerock.com> | Author: Paul C. Bryan <pbryan@anode.ca> | |||
| Change controller: Applications Area Working Group | Change controller: IETF | |||
| 7. Security Considerations | 7. Security Considerations | |||
| This specification has the same security considerations as JSON | This specification has the same security considerations as JSON | |||
| [RFC4627] and JSON Pointer [JSON Pointer]. | [RFC4627] and [JSON-Pointer]. | |||
| 8. Acknowledgements | 8. Acknowledgements | |||
| The following individuals contributed ideas, feedback and wording, | The following individuals contributed ideas, feedback and wording, | |||
| which contributed to the content of this specification: | which contributed to the content of this specification: | |||
| Mike Amundsen, Paul Davis, Dean Landolt, Randall Leeds, Mark | Mike Acar, Mike Amundsen, Paul Davis, Murray S. Kucherawy, Dean | |||
| Nottingham, Julian Reschke, Eli Stevens. | Landolt, Randall Leeds, Mark Nottingham, Julian Reschke, Eli | |||
| Stevens. | ||||
| The structure of a JSON Patch document was influenced by the XML | The structure of a JSON Patch document was influenced by the XML | |||
| Patch document [RFC5261] specification. | Patch document [RFC5261] specification. | |||
| 9. References | 9. References | |||
| 9.1. Normative References | 9.1. Normative References | |||
| [JSON Pointer] | [JSON-Pointer] | |||
| Bryan, P. and K. Zyp, "JSON Pointer", January 2012, <http: | Bryan, P. and K. Zyp, "JSON Pointer", | |||
| //tools.ietf.org/html/draft-ietf-appsawg-json-pointer-00>. | draft-ietf-appsawg-json-pointer-01 (work in progress), | |||
| March 2012. | ||||
| [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. | |||
| [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. | |||
| 9.2. Informative References | 9.2. Informative References | |||
| [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., | [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., | |||
| skipping to change at page 12, line 22 ¶ | skipping to change at page 12, line 42 ¶ | |||
| A JSON Patch document, which will result in an error condition: | A JSON Patch document, which will result in an error condition: | |||
| [ | [ | |||
| { "test": "/baz", "value": "bar" } | { "test": "/baz", "value": "bar" } | |||
| ] | ] | |||
| Author's Address | Author's Address | |||
| Paul C. Bryan (editor) | Paul C. Bryan (editor) | |||
| ForgeRock US, Inc. | ForgeRock | |||
| 201 NE Park Plaza Drive Suite 196 | ||||
| Vancouver, WA 98684 | ||||
| USA | ||||
| Phone: +1 604 783 1481 | Phone: +1 604 783 1481 | |||
| Email: paul.bryan@forgerock.com | Email: pbryan@anode.ca | |||
| End of changes. 27 change blocks. | ||||
| 41 lines changed or deleted | 70 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/ | ||||