JSON Patch

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

JSON patch is defined in RFC6902.

JSON patch defines a JSON document structure for expressing a sequence of operations to apply to a JSON document, in order to change it. The format is suitable to use with the HTTP PATCH method and an "application/json-patch+json" media type.

PATCH /my/data HTTP/1.1
Host: example.org
Content-Length: 326
Content-Type: application/json-patch+json
If-Match: "abc123"

[
  { "op": "test", "path": "/a/b/c", "value": "foo" },
  { "op": "remove", "path": "/a/b/c" },
  { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
  { "op": "replace", "path": "/a/b/c", "value": 42 },
  { "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
  { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
]

Also See

JSON Merge Patch
Kubernetes Strategic Merge Patch