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

  • Home
  • SEARCH
  • 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 8706551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:38:31+00:00 2026-06-13T03:38:31+00:00

What my application Does: I have implemented facebook login for my website. And i

  • 0

What my application Does:
I have implemented facebook login for my website. And i want to save some user info from facebook graph api which i am getting response through Json.

My problem:
I am able to print some Individual values from json response but unable to print values which are nested inside the array.
How can i print the child values from json response?

       *Please see my code below. There i am able to print users info like name and id.
         But unable to get the location of  user from json response.*

Json Output:

        --responseBody---{"id":"100003645579131","name":"Ashutosh Singh","first_name":"Ashutosh","location":{"id":"106377336067638","name":"Bangalore, India"}}
        ---json---{"work":[{"position":{"id":"140001066034322","name":"Senior Inspector"},"location":{"id":"106377336067638","name":"Bangalore, India"},"name":"Ashutosh Singh","last_name":"Singh","gender":"male"}

My code to print above values:

String newUrl = "https://graph.facebook.com/me?access_token=" + accessToken;
            httpclient = new DefaultHttpClient();
            HttpGet httpget = new HttpGet(newUrl);
            System.out.println("Get info from facebook --> executing request: "+ httpget.getURI()); 
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = httpclient.execute(httpget, responseHandler);
               System.out.println("--responseBody---"+responseBody);
            json = (JSONObject) JSONSerializer.toJSON(responseBody);
            System.out.println("---json---"+json);
            facebookId = json.getString("id");//this values are printing fine
            String firstName = json.getString("first_name");//this values are printing fine
            String lastName = json.getString("last_name");//this values are printing fine

            String location=json.getJSONArray("location").toString(); //Unable to print information. Plz give help me. I want to print the location name from the json results.

            System.out.println("locale:"+location); //Unable to print

Error Message:

javax.servlet.ServletException: net.sf.json.JSONException: JSONObject["location"] is not a JSONArray.
            org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
            org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
            org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
            org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
            org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        root cause

        net.sf.json.JSONException: JSONObject["location"] is not a JSONArray.
            net.sf.json.JSONObject.getJSONArray(JSONObject.java:1793)
            com.ebhasin.bstalentscareers.action.SecurityServlet.getUserMailAddressFromJsonResponse(SecurityServlet.java:88)
            com.ebhasin.bstalentscareers.action.FacebookLoginAction.execute(FacebookLoginAction.java:45)
            org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
            org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
            org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
            org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  • 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-06-13T03:38:32+00:00Added an answer on June 13, 2026 at 3:38 am

    As you can see from JSON, location is not a JSON Array , but a JSON Object. You are using getJSONArray() to retrieve it. Use getJSONObject() instead.

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

Sidebar

Related Questions

I have a problem with facebook user login in my android application. I want
I have implemented facebook connect application in one of my website. Everything works fine
I have a Monodroid application that does many webrequests. I am making requests from
i have an Java J2ME application that does (at user request) create HttpConnections to
We have a Facebook application implemented as tabs in a page. However, for certain
I am working on a rails application. I have implemented facebook integration in my
I have implemented a Facebook connect example with my Codeigniter website. I am trying
I have an application that does some long calculations, and I would like to
I have inherited couple of .Net (C#) application which does not have any tracing
I have a QProgressDialog that needs to be popped up when application does the

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.