Skip to content

Allow extraction of claims to JsonNode or ObjectNode #396

@corby

Description

@corby

I've been tooling around with the library (instead of handling JWT tokens myself).

I'd like to be able to access the claims tree directly or be able to call DecodedJWT.getClaims().toJson() that returns either a JsonNode tree or an ObjectNode tree.
I see that the claims are stored internally as JsonNodes, but is there anyway for me to access the tree as JSON objects?

Right now I have to call getClaims().toString() and use a mapper to convert them to a JsonNode object.

My current code:

        ObjectMapper mapper = new ObjectMapper();
        JsonNode nodeProfile = mapper.readTree(new String(Base64.getDecoder().decode(jwtProfile.getPayload())));
        JsonNode nodeToken = mapper.readTree(new String(Base64.getDecoder().decode(jwtToken.getPayload())));

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed:staleIssue or PR has not seen activity recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions