Documentation ¶
Overview ¶
Package jsonpatch provides sane bindings to RFC 6902 (JSON Patch) and RFC 7386 (JSON Merge Patch).
To read in a Patch or Merge Patch, declare the variable, then use json.Unmarshal(); like you would any other JSON document:
bytes, err := ioutil.ReadAll(inputstream) var patch jsonpatch.JSONPatch err := json.Unmarshal(bytes, &patch) err := patch.Apply(oldObj, &newObj)
or
bytes, err := ioutil.ReadAll(inputstream) var patch jsonpatch.JSONMergePatch err := json.Unmarshal(bytes, &patch) err := patch.Apply(oldObj, &newObj)
It does this by wrapping github.com/evanphx/json-patch ; there's very little actual code here; it is just a set of wrappers to provide a nicer interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONMergePatch ¶
type JSONMergePatch json.RawMessage
JSONMergePatch is an RFC 7286 JSON Merge Patch document.
func (JSONMergePatch) Apply ¶
func (patch JSONMergePatch) Apply(in interface{}, out interface{}) locale.Error
Apply the patch to an object; as if the object were marshalled/unmarshalled JSON.
Click to show internal directories.
Click to hide internal directories.