我试图从以下代码中获取 field 名称,但不断出现错误。很明显,该片段存在一些逻辑错误。如何让它显示数据?
字符串callbackUrl = "https://developer.foursquare.com/docs/samples/explore?client_id=6666666&v=20140101&ll=43,-79&client_secret=55555555 ";
FoursquareApi foursquareApi = new FoursquareApi(clientId, client_Secret, callbackUrl);
Result<Recommended> result = foursquareApi.venuesExplore(ll, null, null, null, null,null,query, null, null);
if (result.getMeta().getCode() == 200)
{
for (RecommendationGroup venue : result.getResult().getGroups())
{
for(Recommendation r: venue.getItems())
{
CompactVenue cmp = r.getVenue();
System.out.println(cmp.getName());
}
}
}
else
{
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());
}
程序运行时不显示任何内容。所以我猜这是逻辑错误。
我也有同样的错误。对我来说,它有助于更改 FoursquareApi 的venuesExplore() 方法。
public Result<Recommended> venuesExplore(String ll, Double llAcc, Double alt, Double altAcc, Integer radius, String section, String query, Integer limit, String basis) throws FoursquareApiException {..}
好像是关键字的json解析有问题。所以我改变了:
KeywordGroup keywords = (KeywordGroup) JSONFieldParser.parseEntity(KeywordGroup.class, response.getResponse().getJSONObject("keywords"), this.skipNonExistingFields);
至:
KeywordGroup keywords = new KeywordGroup();
因此结果中没有关键字,但答案的其余部分解析正确。
我是一名优秀的程序员,十分优秀!