Internet Engineering Task Force (IETF)                        P. Hoffman
Request for Comments: 7396                                VPN Consortium
Obsoletes: 7386                                                 J. Snell
Category: Standards Track                                   October 2014
ISSN: 2070-1721

JSON Merge Patch




This specification defines the JSON merge patch format and processing rules. The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of modifications to a target resource's content.

この仕様は、JSONマージパッチ形式と処理ルールを定義します。マージパッチ形式は主に、ターゲットリソースのコンテンツに対する一連の変更を記述する手段としてHTTP PATCHメソッドで使用することを目的としています。

Status of This Memo


This is an Internet Standards Track document.

これはInternet Standards Trackドキュメントです。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.

このドキュメントは、IETF(Internet Engineering Task Force)の製品です。これは、IETFコミュニティのコンセンサスを表しています。公開レビューを受け、インターネットエンジニアリングステアリンググループ(IESG)による公開が承認されました。インターネット標準の詳細については、RFC 5741のセクション2をご覧ください。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at


Copyright Notice


Copyright (c) 2014 IETF Trust and the persons identified as the document authors. All rights reserved.

Copyright(c)2014 IETF Trustおよびドキュメントの作成者として識別された人物。全著作権所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents ( 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.

この文書は、BCP 78およびこの文書の発行日に有効なIETF文書に関するIETFトラストの法的規定(の対象となります。これらのドキュメントは、このドキュメントに関するあなたの権利と制限を説明しているため、注意深く確認してください。このドキュメントから抽出されたコードコンポーネントには、Trust Legal Provisionsのセクション4.eに記載されているSimplified BSD Licenseのテキストが含まれている必要があり、Simplified BSD Licenseに記載されているように保証なしで提供されます。

Table of Contents


   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Processing Merge Patch Documents  . . . . . . . . . . . . . .   3
   3.  Example . . . . . . . . . . . . . . . . . . . . . . . . . . .   4
   4.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .   5
   5.  Security Considerations . . . . . . . . . . . . . . . . . . .   6
   6.  References  . . . . . . . . . . . . . . . . . . . . . . . . .   7
     6.1.  Normative References  . . . . . . . . . . . . . . . . . .   7
     6.2.  Informative References  . . . . . . . . . . . . . . . . .   7
   Appendix A.  Example Test Cases . . . . . . . . . . . . . . . . .   8
   Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .   9
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .   9
1. Introduction
1. はじめに

This specification defines the JSON merge patch document format, processing rules, and associated MIME media type identifier. The merge patch format is primarily intended for use with the HTTP PATCH method [RFC5789] as a means of describing a set of modifications to a target resource's content.

この仕様は、JSONマージパッチドキュメント形式、処理ルール、および関連するMIMEメディアタイプ識別子を定義します。マージパッチ形式は、ターゲットリソースのコンテンツに対する一連の変更を記述する手段として、主にHTTP PATCHメソッド[RFC5789]で使用することを目的としています。

A JSON merge patch document describes changes to be made to a target JSON document using a syntax that closely mimics the document being modified. Recipients of a merge patch document determine the exact set of changes being requested by comparing the content of the provided patch against the current content of the target document. If the provided merge patch contains members that do not appear within the target, those members are added. If the target does contain the member, the value is replaced. Null values in the merge patch are given special meaning to indicate the removal of existing values in the target.


For example, given the following original JSON document:


     "a": "b",
     "c": {
       "d": "e",
       "f": "g"
   Changing the value of "a" and removing "f" can be achieved by
   PATCH /target HTTP/1.1
   Content-Type: application/merge-patch+json
     "c": {
       "f": null

When applied to the target resource, the value of the "a" member is replaced with "z" and "f" is removed, leaving the remaining content untouched.


This design means that merge patch documents are suitable for describing modifications to JSON documents that primarily use objects for their structure and do not make use of explicit null values. The merge patch format is not appropriate for all JSON syntaxes.


2. Processing Merge Patch Documents
2. マージパッチドキュメントの処理

JSON merge patch documents describe, by example, a set of changes that are to be made to a target resource. Recipients of merge patch documents are responsible for comparing the merge patch with the current content of the target resource to determine the specific set of change operations to be applied to the target.


To apply the merge patch document to a target resource, the system realizes the effect of the following function, described in pseudocode. For this description, the function is called MergePatch, and it takes two arguments: the target resource document and the merge patch document. The Target argument can be any JSON value or undefined. The Patch argument can be any JSON value.

マージパッチドキュメントをターゲットリソースに適用するために、システムは、疑似コードで説明されている次の関数の効果を実現します。この説明では、関数はMergePatchと呼ばれ、ターゲットリソースドキュメントとマージパッチドキュメントの2つの引数を取ります。 Target引数は、任意のJSON値または未定義にすることができます。 Patch引数には、任意のJSON値を指定できます。

   define MergePatch(Target, Patch):
     if Patch is an Object:
       if Target is not an Object:
         Target = {} # Ignore the contents and set it to an empty Object
       for each Name/Value pair in Patch:
         if Value is null:
           if Name exists in Target:
             remove the Name/Value pair from Target
           Target[Name] = MergePatch(Target[Name], Value)
       return Target
       return Patch

There are a few things to note about the function. If the patch is anything other than an object, the result will always be to replace the entire target with the entire patch. Also, it is not possible to patch part of a target that is not an object, such as to replace just some of the values in an array.


The MergePatch operation is defined to operate at the level of data items, not at the level of textual representation. There is no expectation that the MergePatch operation will preserve features at the textual-representation level such as white space, member ordering, number precision beyond what is available in the target's implementation, and so forth. In addition, even if the target implementation allows multiple name/value pairs with the same name, the result of the MergePatch operation on such objects is not defined.

MergePatch操作は、テキスト表現のレベルではなく、データ項目のレベルで動作するように定義されています。 MergePatch操作が、空白、メンバーの順序、ターゲットの実装で利用可能な数を超える数の精度などのテキスト表現レベルで機能を保持することは期待されていません。さらに、ターゲット実装で同じ名前の複数の名前/値ペアが許可されている場合でも、そのようなオブジェクトに対するMergePatch操作の結果は定義されていません。

3. Example
3. 例

Given the following example JSON document:


     "title": "Goodbye!",
     "author" : {
       "givenName" : "John",
       "familyName" : "Doe"
     "tags":[ "example", "sample" ],
     "content": "This will be unchanged"
   A user agent wishing to change the value of the "title" member from
   "Goodbye!" to the value "Hello!", add a new "phoneNumber" member,
   remove the "familyName" member from the "author" object, and replace
   the "tags" array so that it doesn't include the word "sample" would
   send the following request:
   PATCH /my/resource HTTP/1.1
   Content-Type: application/merge-patch+json
     "title": "Hello!",
     "phoneNumber": "+01-123-456-7890",
     "author": {
       "familyName": null
     "tags": [ "example" ]

The resulting JSON document would be:


     "title": "Hello!",
     "author" : {
       "givenName" : "John"
     "tags": [ "example" ],
     "content": "This will be unchanged",
     "phoneNumber": "+01-123-456-7890"
4. IANA Considerations
4. IANAに関する考慮事項

This specification registers the following additional MIME media types:


Type name: application


Subtype name: merge-patch+json

サブタイプ名:merge-patch + json

Required parameters: None


Optional parameters: None


Encoding considerations: Resources that use the "application/ merge-patch+json" media type are required to conform to the "application/json" media type and are therefore subject to the same encoding considerations specified in Section 8 of [RFC7159].

エンコーディングの考慮事項:「application / merge-patch + json」メディアタイプを使用するリソースは、「application / json」メディアタイプに準拠する必要があるため、[RFC7159]のセクション8で指定されているものと同じエンコーディングの考慮事項に従います。

Security considerations: As defined in this specification


Published specification: This specification.


Applications that use this media type: None currently known.


Additional information:


         Magic number(s): N/A
         File extension(s): N/A

Macintosh file type code(s): TEXT


Person & email address to contact for further information: IESG


Intended usage: COMMON


Restrictions on usage: None


      Author: James M. Snell <>

Change controller: IESG


5. Security Considerations
5. セキュリティに関する考慮事項

The "application/merge-patch+json" media type allows user agents to indicate their intention for the server to determine the specific set of change operations to be applied to a target resource. As such, it is the server's responsibility to determine the appropriateness of any given change as well as the user agent's authorization to request such changes. How such determinations are made is considered out of the scope of this specification.

「application / merge-patch + json」メディアタイプを使用すると、ユーザーエージェントは、サーバーがターゲットリソースに適用される変更操作の特定のセットを決定する意図を示すことができます。したがって、特定の変更の適切性、およびそのような変更を要求するユーザーエージェントの承認を決定するのはサーバーの責任です。そのような決定がどのように行われるかは、この仕様の範囲外と見なされます。

All of the security considerations discussed in Section 5 of [RFC5789] apply to all uses of the HTTP PATCH method with the "application/merge-patch+json" media type.

[RFC5789]のセクション5で説明されているセキュリティに関する考慮事項はすべて、「application / merge-patch + json」メディアタイプを使用するHTTP PATCHメソッドのすべての使用に適用されます。

6. References
6. 参考文献
6.1. Normative References
6.1. 引用文献

[RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, March 2014, <>.

[RFC7159]ブレイ、T。、「JavaScriptオブジェクト記法(JSON)データ交換形式」、RFC 7159、2014年3月、<>。

6.2. Informative References
6.2. 参考引用

[RFC5789] Dusseault, L. and J. Snell, "PATCH Method for HTTP", RFC 5789, March 2010, <>.

[RFC5789] Dusseault、L.およびJ. Snell、「PATCH Method for HTTP」、RFC 5789、2010年3月、<>。

Appendix A. Example Test Cases
   ORIGINAL        PATCH            RESULT
   {"a":"b"}       {"a":"c"}       {"a":"c"}
   {"a":"b"}       {"b":"c"}       {"a":"b",
   {"a":"b"}       {"a":null}      {}
   {"a":"b",       {"a":null}      {"b":"c"}
   {"a":["b"]}     {"a":"c"}       {"a":"c"}
   {"a":"c"}       {"a":["b"]}     {"a":["b"]}
   {"a": {         {"a": {         {"a": {
     "b": "c"}       "b": "d",       "b": "d"
   }                 "c": null}      }
                   }               }
   {"a": [         {"a": [1]}      {"a": [1]}

["a","b"] ["c","d"] ["c","d"]

["a"、 "b"] ["c"、 "d"] ["c"、 "d"]

   {"a":"b"}       ["c"]           ["c"]
   {"a":"foo"}     null            null
   {"a":"foo"}     "bar"           "bar"
   {"e":null}      {"a":1}         {"e":null,
   [1,2]           {"a":"b",       {"a":"b"}
   {}              {"a":            {"a":
                    {"bb":           {"bb":
                     {"ccc":          {}}}



Many people contributed significant ideas to this document. These people include, but are not limited to, James Manger, Matt Miller, Carsten Bormann, Bjoern Hoehrmann, Pete Resnick, and Richard Barnes.

多くの人々がこの文書に重要なアイデアを提供しました。これらの人々には、James Manger、Matt Miller、Carsten Bormann、Bjoern Hoehrmann、Pete Resnick、およびRichard Barnesが含まれますが、これらに限定されません。

Authors' Addresses


Paul Hoffman VPN Consortium



James M. Snell