MCPcopy
hub / github.com/cli/cli / marshalJSON

Function marshalJSON

pkg/jsoncolor/jsoncolor.go:122–135  ·  view source on GitHub ↗

marshalJSON works like json.Marshal but with HTML-escaping disabled

(v interface{})

Source from the content-addressed store, hash-verified

120
121// marshalJSON works like json.Marshal but with HTML-escaping disabled
122func marshalJSON(v interface{}) ([]byte, error) {
123 buf := bytes.Buffer{}
124 enc := json.NewEncoder(&buf)
125 enc.SetEscapeHTML(false)
126 if err := enc.Encode(v); err != nil {
127 return nil, err
128 }
129 bb := buf.Bytes()
130 // omit trailing newline added by json.Encoder
131 if len(bb) > 0 && bb[len(bb)-1] == '\n' {
132 return bb[:len(bb)-1], nil
133 }
134 return bb, nil
135}

Callers 1

WriteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected