github.com/chain5j/chain5j-pkg@v1.0.7/codec/json/codec.go (about) 1 // Package json 2 // 3 // @author: xwc1125 4 package json 5 6 import ( 7 "github.com/chain5j/chain5j-pkg/codec" 8 ) 9 10 var _ codec.Codec = &Codec{} 11 12 type Codec struct { 13 } 14 15 func NewCodec() *Codec { 16 return &Codec{} 17 } 18 19 func (c *Codec) Encode(v interface{}) ([]byte, error) { 20 return Marshal(v) 21 } 22 23 func (c *Codec) Decode(data []byte, structPrt interface{}) error { 24 return Unmarshal(data, structPrt) 25 }