【发布时间】:2018-05-29 12:36:27
【问题描述】:
我正在使用来自 url 的数据并存储在“输出”字符串中。
如何将其转换为 java 对象和单独的字段?
这是我的代码:
Client client = Client.create();
WebResource webResource = client
.resource(url);
String name = "xxx";
String password = "xxx";
String authString = name + ":" + password;
String authStringEnc = new BASE64Encoder().encode(authString
.getBytes());
//System.out.println("Base64 encoded auth string: " + authStringEnc);
ClientResponse response = webResource.accept("application/json")
.header("Authorization", "Basic " + authStringEnc)
.get(ClientResponse.class);
String output = response.getEntity(String.class);
System.out.println("Output from Server .... \n");
System.out.println(output);
【问题讨论】: