Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:47+00:00 2026-05-27T05:12:47+00:00

Having received the following response from Foursquare, when I try to parse it, I

  • 0

Having received the following response from Foursquare, when I try to parse it, I get the error below:

Response:

{"meta":{"code":200},"response":{"venues":[{"id":"4b1c3ce9f964a520d60424e3","name":"Folsom Lake Bowl","contact":{},"location":{"address":"511 East Bidwell","lat":38.67291745,"lng":-121.165447,"distance":39,"postalCode":"95630","city":"Folsom","state":"CA"},"categories":[{"id":"4bf58dd8d48988d1e4931735","name":"Bowling Alley","pluralName":"Bowling Alleys","shortName":"Bowling Alley","icon":{"prefix":"https://foursquare.com/img/categories/arts_entertainment/bowling_","sizes":[32,44,64,88,256],"name":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":592,"usersCount":284,"tipCount":2},"hereNow":{"count":0}}]}}

Error:

Exception in thread "main" org.codehaus.jettison.json.JSONException: JSONObject["groups"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360)
at org.codehaus.jettison.json.JSONObject.getJSONArray(JSONObject.java:436)
at playaround.FoursquareAPI.get(FoursquareAPI.java:56)
at playaround.FoursquareAPI.main(FoursquareAPI.java:31)

Code:

StringBuilder sb = new StringBuilder();
        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        for (String line; null != (line = reader.readLine());) {
            sb.append(line);
        }
        String output = sb.toString();
        JSONObject json = new JSONObject(output);
        JSONArray venues = json.getJSONObject("response").getJSONArray("groups").getJSONObject(0).getJSONArray("items");
        System.out.println(venues.length());

All I want is to read the response from Foursquare as JSONObject in Java. Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:12:48+00:00Added an answer on May 27, 2026 at 5:12 am

    Reading that stack trace, the JSON is being parsed just fine.

    The problem is that you are trying to read a property that doesn’t exist — “groups”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a way following on from reading a windows *.dmp file Having received a
I get the following error with VS2008: Conversion to enumeration type requires an explicit
I'm having a problem with the following code - function slideContactDetails() { if (sliderState
E I received a good answer at the following link, I need to code
I'm having a hard time Parsing/Formatting a Date string received back from a web
I am having problems changing the 'from' email header in the following script. Everthing
I'm having pretty abnormal work in my application. I'm using following code to enumerate
I am having a problem with formatting a date that I receive from a
I am having trouble accessing the data field. I receive the error: Databinding methods
I'm having trouble creating a global function accessible from within all classes. I receive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.