MarshalIndentNoHTMLString marshals the value to JSON with indentation and SetEscapeHTML(false), returning a string
(v any, prefix, indent string)
| 17 | |
| 18 | // MarshalIndentNoHTMLString marshals the value to JSON with indentation and SetEscapeHTML(false), returning a string |
| 19 | func 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 | |
| 31 | func MustPrettyPrintJSON(v any) string { |
| 32 | str, _ := MarshalIndentNoHTMLString(v, "", " ") |
no test coverage detected