public class JacksonDeserializer<T> extends AbstractDeserializer<T>
ObjectMapper.EOF| Constructor and Description |
|---|
JacksonDeserializer()
Constructor using JJWT's default
ObjectMapper singleton for deserialization. |
JacksonDeserializer(Map<String,Class<?>> claimTypeMap)
Creates a new JacksonDeserializer where the values of the claims can be parsed into given types.
|
JacksonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Constructor using the specified Jackson
ObjectMapper. |
| Modifier and Type | Method and Description |
|---|---|
protected T |
doDeserialize(Reader reader) |
deserialize, deserializepublic JacksonDeserializer()
ObjectMapper singleton for deserialization.public JacksonDeserializer(Map<String,Class<?>> claimTypeMap)
{
"issuer": "https://issuer.example.com",
"user": {
"firstName": "Jill",
"lastName": "Coder"
}
}
Passing a map of ["user": User.class] to this constructor would result in the user claim being
transformed to an instance of your custom User class, instead of the default of Map.
Because custom type parsing requires modifying the state of a Jackson ObjectMapper, this
constructor creates a new internal ObjectMapper instance and customizes it to support the
specified claimTypeMap. This ensures that the JJWT parsing behavior does not unexpectedly
modify the state of another application-specific ObjectMapper.
If you would like to use your own ObjectMapper instance that also supports custom types for
JWT Claims, you will need to first customize your ObjectMapper instance by registering
your custom types and then use the JacksonDeserializer(ObjectMapper) constructor instead.
claimTypeMap - The claim name-to-class map used to deserialize claims into the given typepublic JacksonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
ObjectMapper.objectMapper - the ObjectMapper to use for deserialization.protected T doDeserialize(Reader reader) throws Exception
doDeserialize in class AbstractDeserializer<T>ExceptionCopyright © 2014–2024 jsonwebtoken.io. All rights reserved.