I'd like to extract body of a JWT as a JSON using Jose4j. Is this possible?
We need to support a custom validation that can be arbitrarily easy or very complex depending on the customer. We need the body in the form of a JSON, so that we can pass it as an argument for a customer-specific Javascript method.
Calling
getRawJson()
on theJwtClaims
object obtained fromJwtConsumer
will give you the JSON payload of the JWT, which sounds like what you're looking for.The below snippet from https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples was modified slightly to show
getRawJson()
being used.