在这里,我想使用 Google Places API 获取特定地点的类型,但我显然在如何从 JSON 格式中获取所需的“类型”值方面存在巨大问题。
这是我试图做的
JSONObject predictions = new JSONObject(sb.toString());
JSONArray ja = new JSONArray(predictions.getString("results"));
JSONArray types = ( (JSONObject)ja.get(0)).getJSONArray("types");
for (int i = 0; i < types.length(); i++) {
JSONObject jo = (JSONObject) ja.get(i);
//here I stop
}
这是 JSON 响应
"results" : [
{
"formatted_address" : "529 Kent Street, Sydney NSW, Australia",
"geometry" : {
"location" : {
"lat" : -33.8750460,
"lng" : 151.2052720
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "827f1ac561d72ec25897df088199315f7cbbc8ed",
"name" : "Tetsuya's",
"rating" : 4.30,
"reference" : "CnRmAAAAmmm3dlSVT3E7rIvwQ0lHBA4sayvxWEc4nZaXSSjRtfKRGoYnfr3d5AvQGk4e0u3oOErXsIJwtd3Wck1Onyw6pCzr8swW4E7dZ6wP4dV6AsXPvodwdVyqHgyGE_K8DqSp5McW_nFcci_-1jXb5Phv-RIQTzv5BjIGS0ufgTslfC6dqBoU7tw8NKUDHg28bPJlL0vGVWVgbTg",
"types" : [ "restaurant", "food", "establishment" ]
},
所以你能帮我找出解决这个问题的方法吗?谢谢