draft-ietf-appsawg-json-patch-02.txt   draft-ietf-appsawg-json-patch-03.txt 
Applications Area Working Group P. Bryan, Ed. Applications Area Working Group P. Bryan, Ed.
Internet-Draft ForgeRock Internet-Draft Salesforce.com
Intended status: Informational M. Nottingham, Ed. Intended status: Informational M. Nottingham, Ed.
Expires: January 5, 2013 Rackspace Expires: March 9, 2013 September 5, 2012
July 4, 2012
JSON Patch JSON Patch
draft-ietf-appsawg-json-patch-02 draft-ietf-appsawg-json-patch-03
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 33 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 January 5, 2013. This Internet-Draft will expire on March 9, 2013.
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 17 skipping to change at page 2, line 17
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 . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.3. replace . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.4. move . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.4. move . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.5. copy . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.5. copy . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.6. test . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.6. test . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 6 5. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 7
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7
7. Security Considerations . . . . . . . . . . . . . . . . . . . 8 7. Security Considerations . . . . . . . . . . . . . . . . . . . 8
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 8 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 8
9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 8 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 9
9.1. Normative References . . . . . . . . . . . . . . . . . . . 8 9.1. Normative References . . . . . . . . . . . . . . . . . . . 9
9.2. Informative References . . . . . . . . . . . . . . . . . . 8 9.2. Informative References . . . . . . . . . . . . . . . . . . 9
Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 9 Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 9
A.1. Adding an Object Member . . . . . . . . . . . . . . . . . 9 A.1. Adding an Object Member . . . . . . . . . . . . . . . . . 9
A.2. Adding an Array Element . . . . . . . . . . . . . . . . . 9 A.2. Adding an Array Element . . . . . . . . . . . . . . . . . 10
A.3. Removing an Object Member . . . . . . . . . . . . . . . . 9 A.3. Removing an Object Member . . . . . . . . . . . . . . . . 10
A.4. Removing an Array Element . . . . . . . . . . . . . . . . 10 A.4. Removing an Array Element . . . . . . . . . . . . . . . . 11
A.5. Replacing a Value . . . . . . . . . . . . . . . . . . . . 10 A.5. Replacing a Value . . . . . . . . . . . . . . . . . . . . 11
A.6. Moving a Value . . . . . . . . . . . . . . . . . . . . . . 11 A.6. Moving a Value . . . . . . . . . . . . . . . . . . . . . . 11
A.7. Moving an Array Element . . . . . . . . . . . . . . . . . 11 A.7. Moving an Array Element . . . . . . . . . . . . . . . . . 12
A.8. Testing a Value: Success . . . . . . . . . . . . . . . . . 12 A.8. Testing a Value: Success . . . . . . . . . . . . . . . . . 13
A.9. Testing a Value: Error . . . . . . . . . . . . . . . . . . 12 A.9. Testing a Value: Error . . . . . . . . . . . . . . . . . . 13
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 13 A.10. Adding a nested Member Object . . . . . . . . . . . . . . 13
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 14
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.
The JSON Patch media type "application/json-patch" is a JSON document The JSON Patch media type "application/json-patch" is a JSON document
structure for expressing a sequence of operations to apply to a structure for expressing a sequence of operations to apply to a
skipping to change at page 6, line 34 skipping to change at page 6, line 34
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.6. test 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 that specifies the value to test object contains a "value" member that specifies the value to test
for. If values are or contain objects or arrays, they must be for.
identical (i.e. same order of elements, with the same values).
Here, "equal" means that the target and specified values are of the
same JSON type, and considered equal by the following rules for that
type:
o strings: are considered equal if, after unescaping any sequence(s)
in both strings starting with a reverse solidus, they contain the
same number of Unicode characters and their code points are
position-wise equal.
o numbers: are considered equal if subtracting one from the other
results in 0.
o arrays: are considered equal if they contain the same number of
values, and each value can be considered equal to the value at the
corresponding position in the other array.
o objects: are considered equal if they contain the same number of
members, and each member can be considered equal to a member in
the other object, by comparing their keys as strings, and values
using this list of type-specific rules.
o literals (false, true and null): are considered equal if they are
the same.
Note that this is a logical comparison; e.g., whitespace between the
member values of an array is not significant.
Also, note that ordering of the serialisation of object members is
not significant.
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. Note that as per [RFC5789], PATCH is
atomic.
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
skipping to change at page 13, line 5 skipping to change at page 13, line 35
{ {
"baz": "qux" "baz": "qux"
} }
A JSON Patch document that will result in an error condition: A JSON Patch document that will result in an error condition:
[ [
{ "test": "/baz", "value": "bar" } { "test": "/baz", "value": "bar" }
] ]
A.10. Adding a nested Member Object
An example target JSON document:
{
"foo": "bar"
}
A JSON Patch document:
[
{ "add": "/child", "value": { "grandchild": { } } }
]
The resulting JSON document:
{
"foo": "bar",
"child": {
"grandchild": {
}
}
}
Authors' Addresses Authors' Addresses
Paul C. Bryan (editor) Paul C. Bryan (editor)
ForgeRock Salesforce.com
Phone: +1 604 783 1481 Phone: +1 604 783 1481
Email: pbryan@anode.ca Email: pbryan@anode.ca
Mark Nottingham (editor) Mark Nottingham (editor)
Rackspace
Email: mnot@mnot.net Email: mnot@mnot.net
 End of changes. 13 change blocks. 
22 lines changed or deleted 75 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/