Skip to content

Commit a813ac9

Browse files
committed
escape html encoding to marshal json output completely
1 parent e2123e2 commit a813ac9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/pkg/print/print.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package print
22

33
import (
44
"bufio"
5+
"bytes"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -256,7 +257,12 @@ func (p *Printer) DebugInputModel(model any) {
256257
func (p *Printer) OutputResult(outputFormat string, output any, prettyOutputFunc func() error) error {
257258
switch outputFormat {
258259
case JSONOutputFormat:
259-
details, err := json.MarshalIndent(output, "", " ")
260+
buffer := &bytes.Buffer{}
261+
encoder := json.NewEncoder(buffer)
262+
encoder.SetEscapeHTML(false)
263+
encoder.SetIndent("", " ")
264+
err := encoder.Encode(output)
265+
details := buffer.Bytes()
260266
if err != nil {
261267
return fmt.Errorf("marshal json: %w", err)
262268
}

0 commit comments

Comments
 (0)