diff --git a/protocol/json/server_request.go b/protocol/json/server_request.go index 3817245..d23e716 100644 --- a/protocol/json/server_request.go +++ b/protocol/json/server_request.go @@ -2,6 +2,7 @@ package json import ( "encoding/json" + "strings" "git.loafle.net/commons/rpc-go/protocol" cuej "git.loafle.net/commons/util-go/encoding/json" @@ -130,9 +131,10 @@ func (src *ServerRequestCodec) NewResponse(reply interface{}, err error) ([]byte func (src *ServerRequestCodec) NewResponseWithString(reply string, err error) ([]byte, error) { res := src.newServerResponse(nil, err) - if "" != reply { + r := strings.TrimSpace(reply) + if "" != r { var i interface{} - mErr := json.Unmarshal([]byte(reply), &i) + mErr := json.Unmarshal([]byte(r), &i) if nil != mErr { return nil, mErr }