-
Notifications
You must be signed in to change notification settings - Fork 191
Closed
Description
The > character is decoded as unicode rather than text after applying a json patch. Here's an example:
package main
import (
"fmt"
jsonpatch "github.com/evanphx/json-patch/v5"
)
func main() {
original := []byte(`{
"version": "0.1.0",
"engines": {
"node": ">= 10.16.3"
}
}`)
patchJSON := []byte(`[{"op": "replace", "path": "/version", "value": "0.2.0"}]`)
patch, err := jsonpatch.DecodePatch(patchJSON)
if err != nil {
panic(err)
}
modified, err := patch.ApplyIndent(original, " ")
if err != nil {
panic(err)
}
fmt.Printf("Original document:\n%s\n", original)
fmt.Printf("Modified document:\n%s\n", modified)
}
Output:
Original document:
{
"version": "0.1.0",
"engines": {
"node": ">= 10.16.3"
}
}
Modified document:
{
"version": "0.2.0",
"engines": {
"node": "\u003e= 10.16.3"
}
}
Metadata
Metadata
Assignees
Labels
No labels