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.
usualy, we received data from web frontend.
or them submit form data like this demo=""
ignore form data at the moment.
let we take a look json data. it is an empty string in the json data.
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 <option value="0">please select</option>. Forms also don't submit JSON so there is some part of your code which takes the values of the form and turns it into JSON. This part is where you would normally make sure the JSON values are of the correct type.
because we cant change code of frontend .
we just try to re-write backend using golang from php.
I don't think you not being able to fix your frontend means that the Go JSON parser should make exceptions for invalid JSON.
for JSON. it is valid.
and i think json:",string". it is must able to parse a valid string. any string. empty string also it is a string, valid string. is it?
It's a valid string yes but not a valid number. What if it's "a" which is also a valid string, should it accept that as well? What should the value be then? 0, or 10 or ...?
I think it should produce an error with all strings that are not numbers, like it is now.
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?
If we got an empty string it means that it's default (default for string is "").
If we got a default string it means that we want to use default value for int, isn't it?