You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This also causes the "test" operation of JSON patches to fail whenever the document and the path body have different representations of the same content:
package main
import (
"encoding/json"
"fmt"
jsonpatch "github.com/evanphx/json-patch"
)
func testJsonPatch(patchOps []byte) {
currentState := map[string]any{
"spec": map[string]any{
"test": "<",
},
}
// will escape "<" to \u003c
currentStateJsonBytes, err := json.Marshal(currentState)
if err != nil {
panic(err)
}
patch, err := jsonpatch.DecodePatch(patchOps)
if err != nil {
panic(err)
}
patchedBytes, err := patch.Apply(currentStateJsonBytes)
if err != nil {
panic(err)
}
fmt.Println(string(patchedBytes))
}
func main() {
// Patch guessing the internal serialization specifics
testJsonPatch([]byte(`[{"op":"test","path":"/spec/test","value":"\u003c"}]`)) // {"spec":{"test":"\u003c","unicode":"ß"}}
// Patch with no internal knowledge
testJsonPatch([]byte(`[{"op":"test","path":"/spec/test","value":"<"}]`)) // panic: testing value /spec/test failed: test failed
}
Description
Json string "λJohn" is not equal to "\u03BBJohn" for the function jsonpatch.Equal
I hope to not misinterpret rfc which is stating:
Expected behavior
Equality
Step to reproduce
output:
Test with other implementation
Output:
The text was updated successfully, but these errors were encountered: