Having some sort of proxy between a mobile app and a web-service, we are puzzled by the response when issuing a post request. We receive response with status 200: OK. But we can not find/extract the JSON response body.

    Client client = ClientBuilder.newClient();
    WebTarget webTarget = client.target(WEBSERVICE_BASE_LOCATION + "mobileDevices?operatorCode=KPNSCP");
    String jsonString = "{\"osVersion\":\"4.1\",\"apiLevel\":16,\"devicePlatform\":\"ANDROID\"}";
    Builder builder = webTarget.request();
    Response response = builder.post(Entity.json(jsonString));

We are using JAX-RS. Can someone please provide some hints to extract the JSON body (String) from the server response?

推荐答案

试试这个:

String output = response.getEntity(String.class);

EDIT

感谢@Martin Spamer,我想说的是,它将适用于泽西1号.只有x个罐子.泽西2号.x使用

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

Json相关问答推荐

抓取低于w jolt的对象级别

Bash和echo命令出现意外结果

在Golang中从 struct 手动创建JSON对象

Python将Pandas转换为嵌套的JSON

Flutter -控制器问题-JSON API

jq如何合并两个json对象

使用不同行数的数据创建嵌套Jolt

在这种情况下我如何实现 UnmarshalJSON 并且只为一个接口字段定义特殊行为?

Go - JSON 验证抛出错误,除非我在 struct 中使用指针.为什么?

如何让 JSON.NET 忽略对象关系?

如何在golang中获取 struct 的json字段名称?

如何从 JSON 对象中获取日期

Jackson Json:如何将数组转换为 JsonNode 和 ObjectNode?

json.dumps 打乱了顺序

使用 simplejson 序列化简单类对象的最简单方法?

如何使用 Jackson 定义可选的 json 字段

Android JSON 库的性能和可用性比较

Spring MVC:不反序列化 JSON 请求正文

通过 JSON 发送 HTML 代码

JSON - 是否有任何 XML CDATA 类似功能?