json-patch icon indicating copy to clipboard operation
json-patch copied to clipboard

For V4 and V5, the apply results of the values that do not exist in replace are inconsistent.

Open xuoldkk opened this issue 1 year ago • 1 comments

For V4 and V5, the apply results of the values that do not exist in replace are inconsistent.

V5: replace operation does not apply: doc is missing key: /load

v4: update success.

Is there any consideration for this? Check whether the configuration will be modified in V5.

Also, where are the differences between v4 and v5? Is there a link available? image

What is the difference between the v5 and cmd/json directories?

func TestJsonPatchNewOrRep(t *testing.T) {
	originalFile :=
		[]byte(`{
    "allowedNfDomains": [
        "nfdomain"
    ]
}`)
	rawPatches := []byte(`[
    {
        "op": "replace",
        "path": "/load",
        "value": 30
    }
]`)

	patch, err := jsonpatch.DecodePatch(rawPatches)
	if err != nil {
		fmt.Println("cannot decode jsonpatch", err)
	}

	jsonPatched, err := patch.Apply(originalFile)
	if err != nil {
		fmt.Println("cannot apply jsonpatch: ", err)
	}

	fmt.Println(jsonPatched)
}

xuoldkk avatar Apr 15 '24 00:04 xuoldkk

@evanphx Could you help me to answer it?

xuoldkk avatar Apr 16 '24 01:04 xuoldkk