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 7640521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:41:27+00:00 2026-05-31T08:41:27+00:00

I would like to thank all the users in this community for helping me

  • 0

I would like to thank all the users in this community for helping me get as far as I am in my project today.

I now need your help once again. So far, I am able to establish a connection in my project from this JSON link (REMOVED FOR PRIVACY CONCERNS)

The problem is I am only able to parse one string, (firstName)

Here is my code:

public class JSONActivity extends Activity { 
static TextView http; 
HttpClient client; 
JSONObject json; 

    final static String URL = "REMOVED FOR PRIVACY CONCERNS

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
        http = (TextView) findViewById(R.id.http); 
        client = new DefaultHttpClient(); 
        new Read().execute("firstName"); 

    } 

    public JSONObject getpw(String password) throws ClientProtocolException, 
            IOException, JSONException { 
        StringBuilder url = new StringBuilder(URL); 
        url.append(password); 

        HttpGet get = new HttpGet(url.toString()); 
        HttpResponse r = client.execute(get); 
        int status = r.getStatusLine().getStatusCode(); 
        if (status == 200) { 
            HttpEntity e = r.getEntity(); 
            String data = EntityUtils.toString(e); 
            JSONObject getname = new JSONObject(data); 

            return getname; 
        } else { 
            Toast.makeText(JSONActivity.this, "error", Toast.LENGTH_SHORT); 
            return null; 
        } 
    } 

    public class Read extends AsyncTask<String, Integer, String> { 

        @Override 
        protected String doInBackground(String... arg0) { 
            // TODO Auto-generated method stub 
            try { 
                json = getpw("trustme"); 
                return json.getString("firstName"); 
            } catch (ClientProtocolException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } catch (IOException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } catch (JSONException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } 

            return null; 
        } 

        @Override 
        protected void onPostExecute(String result) { 
            // TODO Auto-generated method stub 
            http.setText(result); 
        } 
    } 
} 

My question is, how can I parse multiple strings rather than just “firstName”?

  • 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-31T08:41:28+00:00Added an answer on May 31, 2026 at 8:41 am

    You can get it all by doing the following:

    String firstname = json.getString("firstName");
    String lastname = json.getString("lastName");
    int checkedIn = json.getInt("checkedIn");
    int updated = json.getInt("checkedindatetime");
    
    JSONObject address = json.getJSONObject("address");
    String streetaddress = address.getString("streetAddress");
    String city = address.getString("city");
    etc...
    
    JSONArray phoneNumbers = json.getJSONArray("phoneNumber");
    String type = phoneNumbers.getJSONObject(0).getString("type");
    etc...
    

    Hope this helps.

    A good resource for looking at json, is this validator.

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

Sidebar

Related Questions

Now I have the rename script like this: cd /Users/KanZ/Desktop/Project/Test/ n=1 for file in
Right first of I would like to thank everyone for helping me out on
Hey all, I would like some advice from the programming community. I am building
Hey all. I would like to get some insight on a question that I
Once again my silliness has struck. I would like to thank everyone who helped
so as title says, I would like to hear your advices what are the
Firstly, thank you for your time taken out to read this and please excuse
I'm using play framework version 1.2.5 and I would like to retrieve all the
MongoDB Question: I would like to find similar bookmarks of other users. Let's say
I'm working on a website and I would like to allow users to be

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.