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
I think the issue is in the standard library itself
package main
import (
"bytes""encoding/json""fmt"
)
funcmain() {
body:=`"{"client_id":"abc123","client_ip":"59.37.125.15","client_version":"1"}"`// body := `{"client_id":"abc123","client_ip":"59.37.125.15","client_version":"1"}`// what we normally do (works as expected with an error)varxinterface{}
err:=json.Unmarshal([]byte(body), &x)
iferr!=nil {
fmt.Printf("Err: %v\n", err)
}
fmt.Printf("x: (%v)\n", x)
// the code used by this library to decode (same standard lib but it succeeds)varyinterface{}
dec:=json.NewDecoder(bytes.NewReader([]byte(body)))
err=dec.Decode(&y)
iferr!=nil {
fmt.Printf("Err: %v\n", err)
}
fmt.Printf("y: (%v)\n", y)
}
The text was updated successfully, but these errors were encountered: