如何读取 JAX-RS 过滤器中的 JSON 负载

How to Read the JSON Payload in a JAX-RS Filter

我正在尝试在每个 api-请求之前执行个性化的 authZ 过程。

我正在使用 JAX-RS/Jersey。

public class AuthorizationRequestFilter implements ContainerRequestFilter {

    @Override
    public void filter(ContainerRequestContext request) throws IOException { 
// How to see JSON payload here?

... 
}

}

request.getEntityStream() 将包含代表正文的 InputStream。你可以在那里阅读。