patch

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTestFailed = errors.New("test failed")
	ErrMissing    = errors.New("missing value")
)

Functions

func JSONEqual

func JSONEqual(a, b []byte) bool

JSONEqual indicates if 2 JSON documents have the same structural equality.

Types

type Operation

type Operation map[string]*json.RawMessage

Operation is a single JSON-Patch step, such as a single 'add' operation.

func (Operation) From

func (o Operation) From() (string, error)

From reads the "from" field of the Operation.

func (Operation) Kind

func (o Operation) Kind() string

Kind reads the "op" field of the Operation.

func (Operation) Path

func (o Operation) Path() (string, error)

Path reads the "path" field of the Operation.

func (Operation) ValueInterface

func (o Operation) ValueInterface() (any, error)

ValueInterface decodes the operation value into an interface.

type Patch

type Patch []Operation

Patch is an ordered collection of Operations.

func (Patch) Apply

func (p Patch) Apply(doc []byte) ([]byte, error)

Apply mutates a JSON document according to the patch, and returns the new document.

func (Patch) ApplyContainer

func (p Patch) ApplyContainer(pd container) (container, error)

func (Patch) ApplyIndent

func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error)

ApplyIndent mutates a JSON document according to the patch, and returns the new document indented.

Jump to

Keyboard shortcuts

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