add transport codec

This commit is contained in:
Asim Aslam
2016-12-06 18:56:57 +00:00
parent bd3c798fd9
commit 49e5636bcd
4 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package json
import (
"encoding/json"
"github.com/micro/go-micro/transport/codec"
)
type jsonCodec struct{}
func (j jsonCodec) Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
func (j jsonCodec) Unmarshal(d []byte, v interface{}) error {
return json.Unmarshal(d, v)
}
func (j jsonCodec) String() string {
return "json"
}
func NewCodec() codec.Codec {
return jsonCodec{}
}