Skip to content
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

encoding/json: Error in Marshalling Slice of Struct type -> affected/package: json #61710

Closed
Prakhar-FF13 opened this issue Aug 2, 2023 · 1 comment

Comments

@Prakhar-FF13
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.20.5 darwin/arm64

Does this issue reproduce with the latest release?

I am on the latest version

What operating system and processor architecture are you using (go env)?

go env GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/prakharkumar/Library/Caches/go-build" GOENV="/Users/prakharkumar/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/prakharkumar/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/prakharkumar/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/homebrew/Cellar/go/1.20.5/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.5/libexec/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.20.5" GCCGO="gccgo" AR="ar" CC="cc" CXX="c++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s6/97rzy6yd76d5rd9fldl8x4dc0000gn/T/go-build4001747071=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ go env

What did you do?

Tried to Marshal a struct type array
type CM struct
{
kind string,
payload []byte,
}

x is an array of CM i.e []CM.

json.Marshal(x) ---> this gives wrong output, but no error is returned.

What did you expect to see?

Marshalled output - example:
[{abc:"some"}, {abc:"thing"}]

What did you see instead?

[{}]

@Prakhar-FF13 Prakhar-FF13 changed the title affected/package: json Error in Marshalling Slice of Struct type -> affected/package: json Aug 2, 2023
@Prakhar-FF13 Prakhar-FF13 changed the title Error in Marshalling Slice of Struct type -> affected/package: json json: Error in Marshalling Slice of Struct type -> affected/package: json Aug 2, 2023
@Prakhar-FF13 Prakhar-FF13 changed the title json: Error in Marshalling Slice of Struct type -> affected/package: json encoding/json: Error in Marshalling Slice of Struct type -> affected/package: json Aug 2, 2023
@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
@golang golang locked and limited conversation to collaborators Aug 1, 2024
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