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

@gopherbot gopherbot commented Oct 19, 2014

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

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 19, 2014

Comment 1:

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

@gopherbot gopherbot added new labels Oct 19, 2014
@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed the repo-main label Apr 14, 2015
@osocurioso

This comment has been minimized.

Copy link
Contributor

@osocurioso osocurioso commented Apr 26, 2015

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Apr 26, 2015

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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.