You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
panic: json: invalid number literal, trying to unmarshal "\"\"" into Number
goroutine 1 [running]:
main.test(0x110164f, 0xa)
/Users/dean/go/json-number-test/main.go:23 +0x14d
main.main()
/Users/dean/go/json-number-test/main.go:13 +0x36
exit status 2
I realize that this was done on purpose and released in 1.14 and it technically doesn't break the Go1 compatibility promise, however, it is a big behavioural breaking change and am hoping it can be reverted.
I cannot speak for the rest of the community but I know many instances where json.Number was specifically used for this very behaviour and now would require code changes to get the same behaviour back; code changes to code that we may not even own.
It was also used because it was a std lib type that supported this behaviour that didn't pull in or make another dependency that caused abstraction leakage.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
json.Number no longer accepts invalid numbers
encoding/json: Number no longer accepts invalid numbers
Feb 27, 2020
It appears that this has been discussed pretty thoroughly, if it is to remain that's ok but if I could request the release notes or somewhere there could be documentation demonstrating the fix or showing the use of an alternative like json.RawMessage just to guide people better during the transition.
Hey @deankarn. As you mentioned, this was discussed in #37308. The release notes contain documentation noting the change. I'm going to close this issue. if you feel like this was closed in error please comment below.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I decoded an empty string into a
json.Number
https://play.golang.org/p/BasiDL88-1O
What did you expect to see?
What did you see instead?
I realize that this was done on purpose and released in 1.14 and it technically doesn't break the Go1 compatibility promise, however, it is a big behavioural breaking change and am hoping it can be reverted.
I cannot speak for the rest of the community but I know many instances where
json.Number
was specifically used for this very behaviour and now would require code changes to get the same behaviour back; code changes to code that we may not even own.It was also used because it was a std lib type that supported this behaviour that didn't pull in or make another dependency that caused abstraction leakage.
The text was updated successfully, but these errors were encountered: