public class JsonPathQuery
extends java.lang.Object
{
"aud": ["uma_authorization", "kafka"],
"iss": "https://auth-server/sso",
"iat": 0,
"exp": 600,
"sub": "username",
"custom": "custom-value",
"roles": {
"client-roles": {
"kafka": ["kafka-user"]
}
},
"custom-level": 9
}
Some examples of valid queries are:
$.custom
$['aud']
$.roles.client-roles.kafka
$['roles']['client-roles']['kafka']
See Jayway JsonPath project for full syntax.
This class takes a JSONPath expression and applies it as-is.
The JWT token is used in its original payload form, for example:
{
"sub": "username",
"iss": "https://auth-server/sso",
"custom": "custom value",
...
}
Usage:
JsonPathQuery query = new JsonPathQuery("$.roles");
JsonNode result = query.apply(jsonObject);
Query is parsed in the first line and any error during parsing results
in JsonPathQueryException.
Matching is thread safe. The normal usage pattern is to initialise the JsonPathFilterQuery object once,
and query it many times concurrently against json objects.
In addition to filtering this helper can also be used to apply JsonPath query to extract a result containing the matching keys.| Modifier and Type | Method and Description |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
apply(com.fasterxml.jackson.databind.JsonNode jsonObject)
Apply the JsonPath query to passed object
|
static JsonPathQuery |
parse(java.lang.String query)
Construct a new JsonPathQuery
|
java.lang.String |
toString() |
public static JsonPathQuery parse(java.lang.String query)
query - The query using the JSONPath syntaxpublic com.fasterxml.jackson.databind.JsonNode apply(com.fasterxml.jackson.databind.JsonNode jsonObject)
jsonObject - Jackson DataBind objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2024. All rights reserved.