Java fi.foyt.foursquare.api.FoursquareApiException:org.json.JSONException:JSONObject[“icon”不是字符串
我从git获取foursquare示例java代码和相同的示例值,并在本地机器上运行,但得到以下异常。 这是我的密码:Java fi.foyt.foursquare.api.FoursquareApiException:org.json.JSONException:JSONObject[“icon”不是字符串,java,Java,我从git获取foursquare示例java代码和相同的示例值,并在本地机器上运行,但得到以下异常。 这是我的密码: String ll = args.length > 0 ? args[0] : "44.3,37.2"; try { FourSquareSampleMain fourSquareSample = new FourSquareSampleMain(); fourSquareSample.searchVenues(ll);
String ll = args.length > 0 ? args[0] : "44.3,37.2";
try {
FourSquareSampleMain fourSquareSample = new FourSquareSampleMain();
fourSquareSample.searchVenues(ll);
} catch (FoursquareApiException e) {
// TODO: Error handling
e.printStackTrace();
}
}
public void searchVenues(String ll) throws FoursquareApiException {
// First we need a initialize FoursquareApi.
FoursquareApi foursquareApi = new FoursquareApi("CLIENT_ID",
"CLIENT_SECRET", null);
// After client has been initialized we can make queries.
Result<VenuesSearchResult> result = foursquareApi.venuesSearch(ll, null, null, null, null, null, null, null,
null, null, null, null, null);
if (result.getMeta().getCode() == 200) {
CompactVenue[] venueList = result.getResult().getVenues();
System.out.println("Compact Venue List size : " + venueList.length);
// if query was ok we can finally we do something with the data
for (CompactVenue venue : venueList) {
// TODO: Do something we the data
System.out.println("Venue Name : " + venue.getName());
}
System.out.println("End of IF Loop: ");
} else {
// TODO: Proper error handling
System.out.println("Error occured: ");
System.out.println(" code: " + result.getMeta().getCode());
System.out.println(" type: " + result.getMeta().getErrorType());
System.out.println(" detail: " + result.getMeta().getErrorDetail());
}
}
我得到以下例外情况:
fi.foyt.foursquare.api.FoursquareApiException:org.json.JSONException:JSONObject[“icon”]不是字符串。
位于fi.foyt.foursquare.api.JSONFieldParser.parseEntity(JSONFieldParser.java:143)
位于fi.foyt.foursquare.api.JSONFieldParser.parseValue(JSONFieldParser.java:194)
位于fi.foyt.foursquare.api.JSONFieldParser.parseEntity(JSONFieldParser.java:141)
位于fi.foyt.foursquare.api.JSONFieldParser.parseEntities(JSONFieldParser.java:57)
在fi.foyt.foursquare.api.FoursquareApi.venuesSearch(FoursquareApi.java:1017)
在FourSquareSampleMain.searchVinces(FourSquareSampleMain.java:57)
位于FourSquareSampleMain.main(FourSquareSampleMain.java:43)
原因:org.json.JSONException:JSONObject[“icon”]不是字符串。
位于org.json.JSONObject.getString(JSONObject.java:658)
位于fi.foyt.foursquare.api.JSONFieldParser.parseValue(JSONFieldParser.java:202)
位于fi.foyt.foursquare.api.JSONFieldParser.parseEntity(JSONFieldParser.java:141)
我错过了什么?请提出建议。我找到了解决办法。这是一个补丁,但它是有效的。详情:
fi.foyt.foursquare.api.entities
下的项目中,就这样希望它能帮上忙同样的问题……实际上,这个问题与FourSquare API中的场地或项目有关,所以我们决定使用它们的端点而不是API,因为我们没有足够的时间来提出和检查它们。但有了endpoint,我的实现就完成了。
String ll = "-33.883056 , 151.216667";// latlong surry hills sydney