func (codec *TCodec) DecodeBytes(v interface{}, bs []byte) error {
	return json.Unmarshal(bs, v)
}
Decode from a byte array.
package rpc
import (
	"encoding/json"
	"io"
	"io/ioutil"
)
type Codec interface {
	EncodeBytes(interface{}) ([]byte, error)
	Encode(interface{}, io.Writer) error
	DecodeBytes(interface{}, []byte) error
	Decode(interface{}, io.Reader) error
}
type TCodec struct {
}
func NewTCodec() Codec {
	return &TCodec{}
}
func (codec *TCodec) Encode(v interface{}, w io.Writer) error {
	bs, err := codec.EncodeBytes(v)
	if err != nil {
		return err
	}
	_, err = w.Write(bs)
	return err
}
func (codec *TCodec) EncodeBytes(v interface{}) ([]byte, error) {
	return json.Marshal(v)
}
func (codec *TCodec) Decode(v interface{}, r io.Reader) error {
	bs, err := ioutil.ReadAll(r)
	if err != nil {
		return err
	}
	return codec.DecodeBytes(v, bs)
}