Marshal serialize the interface{} to []byte
(v interface{})
| 55 | |
| 56 | // Marshal serialize the interface{} to []byte |
| 57 | func (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{} |
| 68 | func (c Codec) Unmarshal(data []byte, v interface{}) error { |