JSON Patch
   HOME

TheInfoList



OR:

JSON Patch is a
web standard Web standards are the formal, non-proprietary standards and other technical specifications that define and describe aspects of the World Wide Web. In recent years, the term has been more frequently associated with the trend of endorsing a set of st ...
format for describing changes in a
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
document. It is meant to be used together with
HTTP The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
Patch Patch or Patches may refer to: Arts, entertainment and media * Patch Johnson, a fictional character from ''Days of Our Lives'' * Patch (''My Little Pony''), a toy * "Patches" (Dickey Lee song), 1962 * "Patches" (Chairmen of the Board song) ...
which allows for the modification of existing HTTP resources. The JSON Patch
media type A media type (also known as a MIME type) is a two-part identifier for file formats and format contents transmitted on the Internet. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication o ...
is application/json-patch+json. 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 Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
patch. The syntax looks like this: 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.


References

JavaScript JSON Open formats {{compu-prog-stub