-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: invalid use of ,string struct tag, trying to unmarshal "" into int #26800
Comments
Doesn't it make sense that this is an error? You're telling it to decode a string into an integer but then don't provide a valid integer in the string. |
@erikdubbelboer
some time, them submit json data like this:
or them submit form data like this demo="" the go code:
zero value of string is "". so, in my opinion, received a zero value of string convert to json. must not get a error. |
@hhniao if your values are supposed to be numbers then it should obviously be |
because we cant change code of frontend . |
I don't think you not being able to fix your frontend means that the Go JSON parser should make exceptions for invalid JSON. |
no, no, no. and i think |
It's a valid string yes but not a valid number. What if it's |
hmm, you are right. thought php can be parse empty string. but it is not standard or valid. for strict of standard, we must write "0" instead "". |
may i should close this issue? |
I think that it should parse empty string as a default parameter (like nil) |
so?! Update i coming?! Working with not my api and cant improve it... plix add! or change |
@asiman161 then what if in Go I have a string but in my JSON I get @bsbak I don't think the Go team will fix this as it's not a bug. |
The error message is there for a reason. Empty strings do not mean
Probably others that I can't think of now. Closing as this is WAI. /cc @mvdan if I missed something. |
https://play.golang.org/p/TabRbDnegfc
#7046
What version of Go are you using (
go version
)?go version go1.10 windows/amd64
The text was updated successfully, but these errors were encountered: