Skip to content

json.RawMessage sometimes encode as it was []byte #17180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mlitvin opened this issue Sep 21, 2016 · 1 comment
Closed

json.RawMessage sometimes encode as it was []byte #17180

mlitvin opened this issue Sep 21, 2016 · 1 comment

Comments

@mlitvin
Copy link

mlitvin commented Sep 21, 2016

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"
@bradfitz
Copy link
Contributor

Dup of #14493

@golang golang locked and limited conversation to collaborators Sep 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants