{"modulePath":"github.com/platform-engineering-labs/jsonpatch","version":"v0.0.0-20260902161127-c895b20a3c9e","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package jsonpatch\n\n## Types\n\n```go\ntype ByPath []JsonPatchOperation\n```\n\n```go\nfunc (a ByPath) Len() int\n```\n\n```go\nfunc (a ByPath) Less(i, j int) bool\n```\n\n```go\nfunc (a ByPath) Swap(i, j int)\n```\n\n```go\ntype CoOwned map[Path]Drainable\n```\nCoOwned restricts removals per path: on a co-owned path only members whose identity is in the path's Drainable set may be removed; every other surplus member is tolerated (no op of any kind). A path absent from the map is not co-owned. An empty Drainable tolerates everything.\n\n```go\ntype Collections struct {\n\tEntitySets EntitySets\n\tArrays     []Path\n\tAtomics    []Path\n\tCoOwned    CoOwned\n}\n```\n\n```go\ntype Drainable map[string]struct{}\n```\nDrainable is the set of member identities remove operations may target on a co-owned path. Identity encoding is the caller's: for a plain set listing the canonical JSON of the element (the same encoding processSet keys on), for an entity set the JSON-marshaled index-field value, for an object path the raw key string.\n\n```go\ntype EntitySets map[Path]Key\n```\n\n```go\nfunc (s EntitySets) Add(path Path, key Key)\n```\n\n```go\nfunc (s EntitySets) Get(path Path) (Key, bool)\n```\n\n```go\ntype JsonPatchOperation struct {\n\tOperation string `json:\"op\"`\n\tPath      string `json:\"path\"`\n\tValue     any    `json:\"value,omitempty\"`\n}\n```\n\n```go\nfunc CreatePatch(a, b []byte, collections Collections, ignoredFields []Path, strategy PatchStrategy) ([]JsonPatchOperation, error)\n```\nCreatePatch creates a patch as specified in [http://jsonpatch.com/](http://jsonpatch.com/)\n\n'a' is original, 'b' is the modified document. Both are to be given as json encoded content. The function will return an array of JsonPatchOperations If ignoreArrayOrder is true, arrays with the same elements but in different order will be considered equal\n\nAn e rror will be returned if any of the two documents are invalid.\n\n```go\nfunc NewPatch(operation, path string, value any) JsonPatchOperation\n```\n\n```go\nfunc (j *JsonPatchOperation) Json() string\n```\n\n```go\nfunc (j *JsonPatchOperation) MarshalJson() ([]byte, error)\n```\n\n```go\ntype Key string\n```\n\n```go\ntype PatchStrategy string\n```\n\n```go\nconst (\n\tPatchStrategyExactMatch   PatchStrategy = \"exact-match\"\n\tPatchStrategyEnsureExists PatchStrategy = \"ensure-exists\"\n\tPatchStrategyEnsureAbsent PatchStrategy = \"ensure-absent\"\n)\n```\n\n```go\ntype Path string\n```\n\n","path":"github.com/platform-engineering-labs/jsonpatch","name":"jsonpatch","synopsis":"","isRedistributable":true}
