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. |
JacksonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
Map<String,Class<?>> claimTypeMap)
Creates a new JacksonDeserializer where the values of the claims can be parsed into given types by registering
a type-converting
Module on the specified 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.public JacksonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
Map<String,Class<?>> claimTypeMap)
Module on the specified ObjectMapper.
A common usage example is to parse custom User object out of a claim, for example the claims:
{
"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 modifies the specified objectMapper argument and customizes it to support the
specified claimTypeMap.
If you do not want your ObjectMapper instance modified, but also want to support custom types for
JWT Claims, you will need to first customize your ObjectMapper instance by registering
your custom types separately and then use the JacksonDeserializer(ObjectMapper) constructor instead
(which does not modify the objectMapper argument).
objectMapper - the objectMapper to modify by registering a custom type-converting
ModuleclaimTypeMap - The claim name-to-class map used to deserialize claims into the given typeprotected T doDeserialize(Reader reader) throws Exception
doDeserialize in class AbstractDeserializer<T>ExceptionCopyright © 2014–2025 jsonwebtoken.io. All rights reserved.