jsonpatch

package
v0.0.0-...-00f1f15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2015 License: AGPL-3.0 Imports: 3 Imported by: 0

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.

type JSONPatch

type JSONPatch evan.Patch

JSONPatch is an RFC 6902 JSON Patch document.

func (JSONPatch) Apply

func (patch JSONPatch) Apply(in interface{}, out interface{}) locale.Error

Apply the patch to an object; as if the object were marshalled/unmarshalled JSON.

type Patch

type Patch interface {
	Apply(in interface{}, out interface{}) locale.Error
}

A Patch document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL