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

Function Marshal

json/json.go:272–284  ·  view source on GitHub ↗

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

(x any)

Source from the content-addressed store, hash-verified

270
271// Marshal is documented at https://golang.org/pkg/encoding/json/#Marshal
272func Marshal(x any) ([]byte, error) {
273 var err error
274 buf := encoderBufferPool.Get().(*encoderBuffer)
275
276 if buf.data, err = Append(buf.data[:0], x, EscapeHTML|SortMapKeys); err != nil {
277 return nil, err
278 }
279
280 b := make([]byte, len(buf.data))
281 copy(b, buf.data)
282 encoderBufferPool.Put(buf)
283 return b, nil
284}
285
286// MarshalIndent is documented at https://golang.org/pkg/encoding/json/#MarshalIndent
287func MarshalIndent(x any, prefix, indent string) ([]byte, error) {

Callers 15

parseRewriteTemplateMapFunction · 0.92
TestIssue136Function · 0.92
TestIssue11Function · 0.92
FuzzFunction · 0.92
MarshalJSONMethod · 0.92
TestStructTagObjectKeyFunction · 0.70
codeInitFunction · 0.70
BenchmarkCodeMarshalFunction · 0.70
benchMarshalBytesFunction · 0.70
TestMarshalFunction · 0.70
TestMarshalBadUTF8Function · 0.70
TestMarshalNumberZeroValFunction · 0.70

Calls 1

AppendFunction · 0.70

Tested by 15

TestIssue136Function · 0.74
TestIssue11Function · 0.74
TestStructTagObjectKeyFunction · 0.56
codeInitFunction · 0.56
BenchmarkCodeMarshalFunction · 0.56
benchMarshalBytesFunction · 0.56
TestMarshalFunction · 0.56
TestMarshalBadUTF8Function · 0.56
TestMarshalNumberZeroValFunction · 0.56
TestMarshalEmbedsFunction · 0.56
TestUnmarshalFunction · 0.56
TestUnmarshalMarshalFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…