如何从javax.ws.rs.core.Response响应中检索JSON响应? [英] How to retrieve JSON Response from a javax.ws.rs.core.Response response?

查看:1113
本文介绍了如何从javax.ws.rs.core.Response响应中检索JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向API发出请求并获得 200 的响应状态代码。

I am making a request to an API and getting a response status code of 200.

api的响应包括 json 响应。

Response of the api includes a json response.

import javax.ws.rs.core.Response;

Response response = webclient.post(SomeReqString);

如何检索 json 响应为来自Web客户端响应的字符串?

How can I retrieve the json response as string from the web client response?

推荐答案

您可以使用以下代码

String responseAsString = response.readEntity(String.class);

这篇关于如何从javax.ws.rs.core.Response响应中检索JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆