func JSONToMsgPack(r io.Reader) *transform.Transformer {
	dec := json.NewDecoder(r)
	return transform.NewTransformer(func() ([]byte, error) {
		var v interface{}
		if err := dec.Decode(&v); err != nil {
			return nil, err
		}
		return msgpack.Marshal(&v)
	})
}
JSONToMsgPack returns an io.Reader that converts JSON messages
into MsgPack messages.
package transutil
import (
	"bufio"
	"bytes"
	"compress/gzip"
	"encoding/json"
	"errors"
	"io"
	"io/ioutil"
	msgpack "gopkg.in/vmihailenco/msgpack.v2"
	"github.com/golang/protobuf/jsonpb"
	"github.com/golang/protobuf/proto"
	"github.com/tidwall/transform"
)
func JSONToPrettyJSON(r io.Reader) *transform.Transformer {
	dec := json.NewDecoder(r)
	return transform.NewTransformer(func() ([]byte, error) {
		var v interface{}
		if err := dec.Decode(&v); err != nil {
			return nil, err
		}
		return json.MarshalIndent(&v, "", "  ")
	})
}
func JSONToUglyJSON(r io.Reader) *transform.Transformer {
	dec := json.NewDecoder(r)
	return transform.NewTransformer(func() ([]byte, error) {
		var v interface{}
		if err := dec.Decode(&v); err != nil {
			return nil, err
		}
		return json.Marshal(&v)
	})
}
func JSONToProtoBuf(r io.Reader, pb proto.Message, multimessage bool) *transform.Transformer {
	var count int
	var dec = json.NewDecoder(r)
	return transform.NewTransformer(func() ([]byte, error) {
		if err := jsonpb.UnmarshalNext(dec, pb); err != nil {
			return nil, err
		}
		if count > 0 && !multimessage {
			return nil, errors.New("not a multimessage stream")
		}
		data, err := proto.Marshal(pb)
		if err != nil {
			return nil, err
		}
		if multimessage {
			data = append(proto.EncodeVarint(uint64(len(data))), data...)
		}
		count++
		return data, err
	})
}
func ProtoBufToJSON(r io.Reader, pb proto.Message, multimessage bool) *transform.Transformer {
	if !multimessage {
		return transform.NewTransformer(func() ([]byte, error) {
			if data, err := ioutil.ReadAll(r); err != nil {
				return nil, err
			} else if len(data) == 0 {
				return nil, io.EOF
			} else if err = proto.Unmarshal(data, pb); err != nil {
				return nil, err
			}
			str, err := (&jsonpb.Marshaler{}).MarshalToString(pb)
			return []byte(str), err
		})
	}
	var szb []byte  
	var msg []byte  
	var br = bufio.NewReader(r)
	return transform.NewTransformer(func() ([]byte, error) {
		var err error
		var sz uint64
		szb = szb[:0]
		for {
			szb = append(szb, 0)
			szb[len(szb)-1], err = br.ReadByte()
			if err != nil {
				if err == io.EOF && len(szb) > 1 {
					return nil, io.ErrUnexpectedEOF
				}
				return nil, err
			}
			if szb[len(szb)-1]>>7 == 0 {
				sz, _ = proto.DecodeVarint(szb)
				break
			}
		}
		mcap := uint64(len(msg))
		if sz >= mcap {
			if mcap == 0 {
				mcap = 1
			}
			for sz >= mcap {
				mcap *= 2
			}
			msg = make([]byte, mcap)
		}
		if _, err := io.ReadFull(br, msg[:sz]); err != nil {
			return nil, err
		}
		if err := proto.Unmarshal(msg[:sz], pb); err != nil {
			return nil, err
		}
		str, err := (&jsonpb.Marshaler{}).MarshalToString(pb)
		return []byte(str), err
	})
}
func MsgPackToJSON(r io.Reader) *transform.Transformer {
	dec := msgpack.NewDecoder(r)
	return transform.NewTransformer(func() ([]byte, error) {
		var v interface{}
		if err := dec.Decode(&v); err != nil {
			return nil, err
		}
		v = remapKeysToStrings(v)
		return json.Marshal(&v)
	})
}
func remapKeysToStrings(v interface{}) interface{} {
	if iv, ok := v.(map[interface{}]interface{}); ok {
		nv := make(map[string]interface{})
		for k, v := range iv {
			nv[k.(string)] = remapKeysToStrings(v)
		}
		return nv
	}
	return v
}