JSON Patch

JSON Patch
Filename extension
.json-patch
Internet media type
application/json-patch+json
Developed byP. Bryan, M. Nottingham
Extended fromJSON

JSON Patch is a web standard format for describing changes in a JSON document. It is meant to be used together with HTTP PATCH which allows for the modification of existing HTTP resources. The JSON Patch media type is application/json-patch+json.

Overview

A JSON Patch document is structured as a JSON array of objects where each object contains one of the six JSON Patch operations: add, remove, replace, move, copy, and test. This structure was influenced by the specification of XML patch. The syntax looks like this:[1][2]

There is one operation per object, though there can be many objects/operations in every array. These operations are performed in order; the first operation in the array goes first, the second operation acts upon the result of the previous operation, and so on.

JSON Patch documents are atomic in that if one operation in the document fails, then no operation will be carried out.

Operations

The operations do the following:

Add
adds a value into an object or array.
Remove
removes a value from an object or array.
Replace
replaces a value. Logically identical to using remove and then add.
Copy
copies a value from one path to another by adding the value at a specified location to another location.
Move
moves a value from one place to another by removing from one location and adding to another.
Test
tests for equality at a certain path for a certain value.[3]

References

  1. ^ Mark, Nottingham; Paul, Bryan (April 2013). "JavaScript Object Notation (JSON) Patch". tools.ietf.org. Retrieved 2016-12-04.
  2. ^ "mnot's blog: Why PATCH is Good for Your HTTP API". www.mnot.net. Retrieved 2016-12-04.
  3. ^ Foster, Ben (11 April 2016). "How to perform partial resource updates with JSON Patch and ASP.NET Core". benfoster.io.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.