3. Example (例)
3. Example (例)
次の例の JSON ドキュメントがあるとします:
{
"title": "Goodbye!",
"author" : {
"givenName" : "John",
"familyName" : "Doe"
},
"tags":[ "example", "sample" ],
"content": "This will be unchanged"
}
ユーザーエージェントが "title" メンバーの値を "Goodbye!" から "Hello!" に変更し, 新しい "phoneNumber" メンバーを追加し, "author" オブジェクトから "familyName" メンバーを削除し, "tags" 配列を置き換えて "sample" という単語を含まないようにしたい場合, 次のリクエストを送信します:
PATCH /my/resource HTTP/1.1
Host: example.org
Content-Type: application/merge-patch+json
{
"title": "Hello!",
"phoneNumber": "+01-123-456-7890",
"author": {
"familyName": null
},
"tags": [ "example" ]
}
結果の JSON ドキュメントは次のようになります:
{
"title": "Hello!",
"author" : {
"givenName" : "John"
},
"tags": [ "example" ],
"content": "This will be unchanged",
"phoneNumber": "+01-123-456-7890"
}