public class JacksonDeserializer<T> extends Object implements Deserializer<T>
| Constructor and Description |
|---|
JacksonDeserializer() |
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) |
public JacksonDeserializer()
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)
public T deserialize(byte[] bytes) throws DeserializationException
deserialize in interface Deserializer<T>DeserializationExceptionprotected T readValue(byte[] bytes) throws IOException
IOExceptionCopyright © 2014–2020 jsonwebtoken.io. All rights reserved.