0
我真的被卡住了。我试图从Facebook查询附近的地方,我实际上得到了json格式的结果。这是我使用的代码。解析Facebook JSON数组
@Override
public void getNearbyPlaces(final Session session){
Request request = Request.newPlacesSearchRequest(session, _gpsTracker.getLocation(), 8000, 1, "restaurant", new Request.GraphPlaceListCallback() {
@Override
public void onCompleted(List<GraphPlace> places, Response response) {
ListIterator<GraphPlace> _allplaces = places.listIterator();
while(_allplaces.hasNext()){
String singlePlace = _allplaces.next().toString();
}
if(response.getError() != null){
Toast.makeText(getActivity(), "Error Occured", Toast.LENGTH_SHORT).show();
}
}
});
request.executeAsync();
}
,这是结果我得到
GraphObject{graphObjectClass=GraphPlace, state={"id":"196223377081320","category":"Local business","location":{"state":"","zip":"","longitude":32.6246565296,"latitude":0.23724219554666,"country":"Uganda","city":"Kampala","street":""},"category_list":[{"id":"273819889375819","name":"Restaurant"},{"id":"164243073639257","name":"Hotel"}],"name":"Munyonyo Speke Resort"}}
但是,我没能提取名称,ID和坐标。