3. Example (Esempio)
3. Example (Esempio)
Dato il seguente documento JSON di esempio:
{
"title": "Goodbye!",
"author" : {
"givenName" : "John",
"familyName" : "Doe"
},
"tags":[ "example", "sample" ],
"content": "This will be unchanged"
}
Un agente utente che desidera modificare il valore del membro "title" da "Goodbye!" a "Hello!", aggiungere un nuovo membro "phoneNumber", rimuovere il membro "familyName" dall'oggetto "author" e sostituire l'array "tags" in modo che non includa la parola "sample" invierebbe la seguente richiesta:
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" ]
}
Il documento JSON risultante sarebbe:
{
"title": "Hello!",
"author" : {
"givenName" : "John"
},
"tags": [ "example" ],
"content": "This will be unchanged",
"phoneNumber": "+01-123-456-7890"
}