-
Notifications
You must be signed in to change notification settings - Fork 993
json: cannot unmarshal object into Go value of type jwt.Claims #345
Comments
|
The error is that json decoder could not decode to variable of type Claims, because Claims is an interface and decoder do not know what real type is With error: https://play.golang.org/p/WT5yd2X_iCI |
@rentateamdev1 , use a pointer to your custom claim instead of a value one. An interface is a tuple (concrete type, value). If you use a pointer type (
Or for your example with error : |
I used this is ok
|
I'm not the OP, but @kheraud 's solution fixed this for me. The example for a custom claims type has this same logic, so maybe just a quick explanatory comment on the example could close this issue? |
https://github.com/dgrijalva/jwt-go/blob/master/parser.go#L131
this decode code always returns decode error
json: cannot unmarshal object into Go value of type jwt.Claims
because claims variable is declared as interface not a struct
The text was updated successfully, but these errors were encountered: