MCPcopy
hub / github.com/golang-jwt/jwt / parseString

Method parseString

map_claims.go:92–109  ·  view source on GitHub ↗

parseString tries to parse a key in the map claims type as a [string] type. If the key does not exist, an empty string is returned. If the key has the wrong type, an error is returned.

(key string)

Source from the content-addressed store, hash-verified

90// If the key does not exist, an empty string is returned. If the key has the
91// wrong type, an error is returned.
92func (m MapClaims) parseString(key string) (string, error) {
93 var (
94 ok bool
95 raw any
96 iss string
97 )
98 raw, ok = m[key]
99 if !ok {
100 return "", nil
101 }
102
103 iss, ok = raw.(string)
104 if !ok {
105 return "", newError(fmt.Sprintf("%s is invalid", key), ErrInvalidType)
106 }
107
108 return iss, nil
109}

Callers 3

GetIssuerMethod · 0.95
GetSubjectMethod · 0.95

Calls 1

newErrorFunction · 0.85

Tested by 1