Skip to content

Commit 19ace45

Browse files
Matovidloclaude
andcommitted
revert(json): remove SetEscapeHTML(false) from Encode function
The SetEscapeHTML(false) change did not propagate through orderedmap.MarshalJSON() which creates its own json.NewEncoder without the setting. Since all local JSON files go through the orderedmap path, the change had inconsistent behavior and risked altering encoding of existing configs. Revert to original json.MarshalIndent/json.Marshal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 70aad84 commit 19ace45

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

internal/pkg/encoding/json/json.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ import (
1010
type RawMessage = json.RawMessage
1111

1212
func Encode(v any, pretty bool) ([]byte, error) {
13-
var buf bytes.Buffer
14-
enc := json.NewEncoder(&buf)
15-
enc.SetEscapeHTML(false)
13+
var data []byte
14+
var err error
1615
if pretty {
17-
enc.SetIndent("", " ")
16+
data, err = json.MarshalIndent(v, "", " ")
17+
data = append(data, '\n')
18+
} else {
19+
data, err = json.Marshal(v)
1820
}
19-
if err := enc.Encode(v); err != nil {
21+
if err != nil {
2022
return nil, processJSONEncodeError(err)
2123
}
22-
data := buf.Bytes()
23-
if pretty {
24-
// json.Encoder always appends a newline, which matches the previous behavior for pretty output.
25-
return data, nil
26-
}
27-
// For non-pretty output, strip the trailing newline appended by json.Encoder.
28-
return bytes.TrimRight(data, "\n"), nil
24+
return data, nil
2925
}
3026

3127
func MustEncode(v any, pretty bool) []byte {

0 commit comments

Comments
 (0)