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");
}
感谢