我有一个返回JSON响应的网址,以下是该代码:
String usepass = "XXXXXX" + ":" + "XXXXXXx#";
String basicAuth = "Basic "
+ javax.xml.bind.DatatypeConverter.printBase64Binary(usepass.getBytes());
String url = "http://XXXXXXX/jira/rest/api/2/issue/CQ-12836?expand=changelog";
URL obj = new URL("http://XXXXXXX/jira/rest/api/2/issue/CQ-12836?expand=changelog");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// optional default is GET
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("Authorization", basicAuth);
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
String jsonRespose = response.toString();
in.close();
//print in String
System.out.println("*****print json*****");
但是,现在,如果更改返回JSON列表而不是单个JSON列表的URL,那么我该如何在Java中处理呢?我必须在这里进行哪些更改?
请在这里帮助我。