encoding/json: support unmarshaling empty string into float #47102
Labels
FeatureRequest
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
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
)?mac M1
go env
OutputWhat did you do?
What did you expect to see?
Hope that err can be nil.
Hope that encoding/json can add a new tag like omitempty to ignore the parse err when the input string is "".
This issue has mentioned: #26800
In this issue, "" parse to 0 is not good, I agree that.
But hope that can add a new way for us to ignore this kinds of err instead of throwing an error.
Because we can ofter receive the json string like "price":"", it's right format, but it's inconvenient for us to parse it when there are a lot of fields like this, now we have to define all the fields as string, and parse it one by one using strconv.ParseFloat(), and judge every error and ignore the string "" ...
Thanks.
What did you see instead?
err: json: invalid use of ,string struct tag, trying to unmarshal "" into int64
The text was updated successfully, but these errors were encountered: