小编Sud*_*hir的帖子

使用jersey客户端将JSON响应读取为字符串

我正在使用jersey客户端将文件发布到REST URI,该URI返回响应为json.我的要求是将响应按原样(json)读取到字符串.

以下是将数据发布到Web服务的代码段.

final ClientResponse clientResp = resource.type(
            MediaType.MULTIPART_FORM_DATA_TYPE).
            accept(MediaType.APPLICATION_JSON).
            post(ClientResponse.class, inputData);
     System.out.println("Response from news Rest Resource : " + clientResp.getEntity(String.class)); // This doesnt work.Displays nothing.
Run Code Online (Sandbox Code Playgroud)

clientResp.getLength()有281个字节,这是响应的大小,但clientResp.getEntity(String.class)什么都不返回.

任何想法在这里可能是不正确的?

string json response jersey

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

jersey ×1

json ×1

response ×1

string ×1