MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / Marshal

Method Marshal

pkg/encoding/json_encoding.go:35–45  ·  view source on GitHub ↗

Marshal json encode and gzip

(v interface{})

Source from the content-addressed store, hash-verified

33
34// Marshal json encode and gzip
35func (jz JSONGzipEncoding) Marshal(v interface{}) ([]byte, error) {
36 buf, err := json.Marshal(v)
37 if err != nil {
38 return nil, err
39 }
40 // var bufSizeBefore = len(buf)
41
42 buf, err = GzipEncode(buf)
43 // log.Infof("gzip_json_compress_ratio=%d/%d=%.2f", bufSizeBefore, len(buf), float64(bufSizeBefore)/float64(len(buf)))
44 return buf, err
45}
46
47// Unmarshal json encode and gzip
48func (jz JSONGzipEncoding) Unmarshal(data []byte, value interface{}) error {

Callers 1

TestEncodingErrorFunction · 0.95

Calls 2

GzipEncodeFunction · 0.85
MarshalMethod · 0.65

Tested by 1

TestEncodingErrorFunction · 0.76