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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:19:24+00:00 2026-06-01T22:19:24+00:00

I have a question that I am a little bit confused about. I am

  • 0

I have a question that I am a little bit confused about. I am quite new to JSON and getting JSON values in the android API. I am trying to access an array within the response I get. the JSON code I am getting is something like this:

Response:
{
"event": {  
    "participants": []
},
"status": "success"
}

How would I access the participants array and store their values. This is what I am trying at the moment… but I dont appear to be getting what I want.

try{
                //get the JSON values from the URL.
                JSONObject json = jParser.getJSONFromUrl("http://somesite.com/api/find?"+"somevar="+someJavaStringVar);

                json_event = json.getJSONObject("event");

                JSONArray json_array_participants = json_event.getJSONArray("participants");  

} catch(JSONException e) {

}

The thing I am mostly confused about is… what is the arrays type equivalent to. Any advice or reasoning as to the correct way to get ahold of that variables value would be great… thanks guys.. :).

  • 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-01T22:19:26+00:00Added an answer on June 1, 2026 at 10:19 pm

    Think JSON is really just a key-value pairing. The JSONArray type is just an array full of objects (like Object[]) – it has no idea what the objects it contains are or what they’re to be used for. Its up to you to assign meaning to the JSON stream based on what you know of the source. From what I see of your code, most of it looks fine, though I don’t know what your jParser.getJSONFromURL() is doing. Typically, you would build the JSON from the response string like so:

    String jsonString = getJSONFromUrl("http://somesite.com/api/find?"+"somevar="+someJavaStringVar);
    
    JSONObject json = new JSONObject(jsonString)
    
    JSONObject json_event = json.getJSONObject("event");
    
    JSONArray json_array_participants = json_event.getJSONArray("participants");
    

    You can iterate through the array like any other array to get subobjects or whatever:

    for(int i=0; i < json_array_participants.getLength(); i++) {
      JSONObject participant = json_array_participants.getJSONObject(i);
      // Do stuff
    }
    

    As a side note – I WOULDN’T use GSON until you understand the underlying protocol, at least a little – because you never know when you might want to parse your JSON from a different language for some reason.

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

Sidebar

Related Questions

At the moment I'm a little bit confused about the lifecycle management in Android.
I have this little question that's been on my mind for a while now.
I little while back I posted this question . I have updated that question
I have a homework question please help with a little explanation so that I
I have a question that may be quite naive, but I feel the need
I'm sometimes a little bit confused about concepts in Java EE application development. Let's
I have a question about a If-statement that is really making me crazy. It
This is a little different than the questions that have already been asked on
I have a question that should be quick and easy for you guys to
I have a question that I just don't feel like I've found a satisfactory

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.