MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / MarshalIndentNoHTMLString

Function MarshalIndentNoHTMLString

pkg/util/utilfn/marshal.go:19–29  ·  view source on GitHub ↗

MarshalIndentNoHTMLString marshals the value to JSON with indentation and SetEscapeHTML(false), returning a string

(v any, prefix, indent string)

Source from the content-addressed store, hash-verified

17
18// MarshalIndentNoHTMLString marshals the value to JSON with indentation and SetEscapeHTML(false), returning a string
19func MarshalIndentNoHTMLString(v any, prefix, indent string) (string, error) {
20 var buf bytes.Buffer
21 encoder := json.NewEncoder(&buf)
22 encoder.SetEscapeHTML(false)
23 encoder.SetIndent(prefix, indent)
24 err := encoder.Encode(v)
25 if err != nil {
26 return "", err
27 }
28 return strings.TrimRight(buf.String(), "\n"), nil
29}
30
31func MustPrettyPrintJSON(v any) string {
32 str, _ := MarshalIndentNoHTMLString(v, "", " ")

Callers 2

MustPrettyPrintJSONFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected