Marshal json encode and gzip
(v interface{})
| 33 | |
| 34 | // Marshal json encode and gzip |
| 35 | func (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 |
| 48 | func (jz JSONGzipEncoding) Unmarshal(data []byte, value interface{}) error { |