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
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
darwin/amd64
What did you do?
package main
import (
"encoding/json"
"fmt"
"strings"
)
func main() {
s := `01`
sr := strings.NewReader(s)
dec := json.NewDecoder(sr)
var f float64
err := dec.Decode(&f)
fmt.Println(f, err)
}
What did you expect to see?
an error related to an invalid number
What did you see instead?
0 <nil>
The text was updated successfully, but these errors were encountered:
The decoder decodes a valid JSON value (0) and gives it back. The 1 is unconsumed. If you decode again, you will get the next JSON value in the stream (1).
cespare
changed the title
encoding/json: Decode does not error on invalid leading zeros.
encoding/json: Decode does not error on invalid leading zeros
Jan 3, 2021
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
)?darwin/amd64
What did you do?
What did you expect to see?
an error related to an invalid number
What did you see instead?
The text was updated successfully, but these errors were encountered: