Closed
Description
json.Marshal sometimes encode json.RawMessage as it was []byte, that is it put the base64 encoding of the content, instead of the raw content.
The "sometimes" seems to be when the enclosing structure is passed by value to json.Marshal (and not when a pointer is passed).
See https://play.golang.org/p/RxMaWUHjrS
I expected both invocation to give identical results.
as well as reproducing in the playground I tested it (with the same results) on os X:
go version go1.7 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/moshe/Documents/code/gopath"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y6/cd3mw6tx1qn89g0vn2pdz4gc0000gn/T/go-build778754863=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
and linux:
go version go1.7.1 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build250125797=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"