我尝试按照示例http://www.mkyong.com/webservices/jax-rs/restful-java-client-with-jersey-client/
在Java应用程序中使用REST Web服务当我尝试打印输出时,它会打印“ ...”(3点)。这是什么意思?如何从网络服务调用中获得正确的可读字符串输出?
我可以通过浏览器看到JSON:
{“ ContentEncoding”:null,“ ContentType”:null,“ Data”:[{“ ID”:“ 0”,“ NAME”:“ abc”},{“ ID”:“ 1”,“ NAME “:” xyz“}],” MaxJsonLength“:null,” RecursionLimit“:null}
代码:
try {
Client client = Client.create();
WebResource webResource = client
.resource("https://someurl/api/Projects");
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
String output = response.getEntity(String.class);
System.out.println("JsonString: " + output);
} catch (Exception e) {
e.printStackTrace();
}