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: output not always valid input #8962

Closed
gopherbot opened this issue Oct 19, 2014 · 3 comments
Closed

encoding/json: output not always valid input #8962

gopherbot opened this issue Oct 19, 2014 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by 2852914@wessie.info:

What does 'go version' print?

go version go1.3.3 linux/amd64

What steps reproduce the problem?

http://play.golang.org/p/MQmD9eJmYY

1. Define type with underlying type []byte
2. Marshal a value of said type
3. Try to Unmarshal the result from Marshal

What happened?

Received an error "json: cannot unmarshal string into Go value of type
main.Bytes"

What should have happened instead?

Marshal should either refuse to encode the type, or Unmarshal should unmarshal the
result correctly.

The error happens because the encoding process compares against the slice element type,
while the decoding process compares against the slice type.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.5.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed the repo-main label Apr 14, 2015
@osocurioso
Copy link
Contributor

Mailed http://golang.org/cl/9371.

@gopherbot
Copy link
Author

CL https://golang.org/cl/9371 mentions this issue.

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

5 participants