MCPcopy Create free account
hub / github.com/segmentio/encoding / MarshalIndent

Function MarshalIndent

json/json.go:287–299  ·  view source on GitHub ↗

MarshalIndent is documented at https://golang.org/pkg/encoding/json/#MarshalIndent

(x any, prefix, indent string)

Source from the content-addressed store, hash-verified

285
286// MarshalIndent is documented at https://golang.org/pkg/encoding/json/#MarshalIndent
287func MarshalIndent(x any, prefix, indent string) ([]byte, error) {
288 b, err := Marshal(x)
289
290 if err == nil {
291 tmp := &bytes.Buffer{}
292 tmp.Grow(2 * len(b))
293
294 Indent(tmp, b, prefix, indent)
295 b = tmp.Bytes()
296 }
297
298 return b, err
299}
300
301// Unmarshal is documented at https://golang.org/pkg/encoding/json/#Unmarshal
302func Unmarshal(b []byte, x any) error {

Callers 2

TestOmitEmptyFunction · 0.85
TestStringTagFunction · 0.85

Calls 3

IndentFunction · 0.85
BytesMethod · 0.80
MarshalFunction · 0.70

Tested by 2

TestOmitEmptyFunction · 0.68
TestStringTagFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…