MCPcopy Create free account
hub / github.com/DoNewsCode/core / Marshal

Method Marshal

codec/json/json.go:57–65  ·  view source on GitHub ↗

Marshal serialize the interface{} to []byte

(v interface{})

Source from the content-addressed store, hash-verified

55
56// Marshal serialize the interface{} to []byte
57func (c Codec) Marshal(v interface{}) ([]byte, error) {
58 if m, ok := v.(proto.Message); ok {
59 return c.marshalOptions.Marshal(m)
60 }
61 if c.indent != "" {
62 return json.MarshalIndent(v, c.prefix, c.indent)
63 }
64 return json.Marshal(v)
65}
66
67// Unmarshal deserialize the []byte to interface{}
68func (c Codec) Unmarshal(data []byte, v interface{}) error {

Callers

nothing calls this directly

Implementers 3

Codeccodec/yaml/yaml.go
Codeccodec/json/json.go
CodecParserconfig/codec_parser.go

Calls 1

MarshalMethod · 0.65

Tested by

no test coverage detected