Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Venus Search Exception #10

Open
Kml55 opened this issue Apr 23, 2015 · 1 comment
Open

Venus Search Exception #10

Kml55 opened this issue Apr 23, 2015 · 1 comment

Comments

@Kml55
Copy link

Kml55 commented Apr 23, 2015

I am getting jsonexception on venus search. I call venus search like below

public static void venuesInTheBox(double currLat,double currLon){
         // First we need a initialize FoursquareApi. 
        FoursquareApi foursquareApi = new FoursquareApi("myclientid", "myclientsecret", "");
        SimpleDateFormat df = new SimpleDateFormat("YYYYMMDD");
        foursquareApi.setVersion(df.format(Calendar.getInstance().getTime()));
        // After client has been initialized we can make queries.
        Result<VenuesSearchResult> result;
        try {
            result = foursquareApi.venuesSearch(currLat+","+currLon, null, null, null, null, null, null, null, null, null, null);
            if (result.getMeta().getCode() == 200) {
                  // if query was ok we can finally we do something with the data
                  for (CompactVenue venue : result.getResult().getVenues()) {
                    // TODO: Do something we the data
                    System.out.println(venue.getName());
                  }
            }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()); 
            }
        }catch(FoursquareApiException e){
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

The exception is this

fi.foyt.foursquare.api.FoursquareApiException: org.json.JSONException: JSONObject["specials"] is not a JSONArray.

What should I do ?

@Kml55
Copy link
Author

Kml55 commented Apr 24, 2015

I downloaded source code and debugged it.I added this class to the models.

package fi.foyt.foursquare.api.entities;

import fi.foyt.foursquare.api.FoursquareEntity;

public class Icon implements FoursquareEntity{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String prefix;
    private String suffix;
    public String getPrefix() {
        return prefix;
    }
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
    public String getSuffix() {
        return suffix;
    }
    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }
}

and changed Category models' Icon field from String to Icon. It works now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant