Closed donkw closed 4 years ago
claims := jwt.MapClaims{} token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) { return j.AccessTokenSigningKey, nil } fmt.Printf("uint number: %+v\n", claims["uintnum"]) // out: 9.6863578e+07
uintNum := claims["uintnum"].(uint) // panic fmt.Printf("uint number: %+v\n", uintNum )
This will panic: interface conversion: interface {} is float64, not uint, but the value of uintnum is an uint number. How could i get uint number from claims ?
interface conversion: interface {} is float64, not uint
uintnum
uint
claims
https://github.com/dgrijalva/jwt-go/blob/master/example_test.go#L56 This will help.
claims := jwt.MapClaims{} token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) { return j.AccessTokenSigningKey, nil } fmt.Printf("uint number: %+v\n", claims["uintnum"]) // out: 9.6863578e+07
uintNum := claims["uintnum"].(uint) // panic fmt.Printf("uint number: %+v\n", uintNum )
This will panic:
interface conversion: interface {} is float64, not uint
, but the value ofuintnum
is anuint
number. How could i getuint
number fromclaims
?