0
我目前正在使用Yelp Fusion API來檢索業務信息。到目前爲止,我已經能夠得到我的POST請求的響應,但只能得到像輸出一樣的整個JSON。有什麼方法可以讓我過濾我的結果嗎?所以只需要檢索一個特定的鍵值和JSON輸出中的值。到目前爲止我的代碼如下所示:處理POST回覆
try {
String req = "https://api.yelp.com/v3/businesses/search?";
req += "term=" + term + "&location=" + location;
if(category != null) {
req += "&category=" + category;
}
URL url = new URL(req);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Bearer " + ACCESSTOKEN);
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuffer buffer = new StringBuffer();
String inputLine = reader.readLine();
buffer.append(inputLine);
System.out.println(buffer.toString());
reader.close();
} catch (Exception e) {
System.out.println("Error Connecting");
}
感謝