Skip to content

Use Patchwerk to create RFC6902 JSON patches

License

Notifications You must be signed in to change notification settings

onewealthplace/patchwerk

 
 

Repository files navigation

Patchwerk

Patchwerk logo

Go JSON patch

Build Status

Use Patchwerk to create RFC6902 JSON patches.

At the moment of writing this is the only working Go library for creating JSON patches. If you wish to apply the patches I recommend using evanphx/json-patch (it only allows for applying patches, not generating them).

The project was originally cloned from mattbaird/jsonpatch.

Installation

go get github.com/herkyl/patchwerk

Usage

package main

import (
	"fmt"
	"github.com/herkyl/patchwerk"
)

func main() {
	a := `{"a":100, "b":200}`
	b := `{"a":100, "b":200, "c":300}`
	patch, err := patchwerk.DiffBytes([]byte(a), []byte(b))
	if err != nil {
		fmt.Printf("Error creating JSON patch: %v", err)
		return
	}
	fmt.Println(string(patch)) // [{"op": "add", "path": "/c", "value": 300}]
}

About

Use Patchwerk to create RFC6902 JSON patches

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%