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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:17:35+00:00 2026-06-19T01:17:35+00:00

I can’t seem too get the second layer in the JSON Array. What I

  • 0

I can’t seem too get the second layer in the JSON Array.
What I want is, to get all the names from the Categories, and then I want to sent the “forums id” trough a intent to an different Activity.
If it helps, I followed this tutorial and I’m getting my JSON array from here

Part of JSON Array

{
"categories": [{
    "name": "Facepunch",
    "forums": [{
        "id": 6,
        "name": "General Discussion",
        "viewing": 217
    }, {
        "id": 60,
        "name": "Fast Threads",
        "viewing": 188
    }, {
        "id": 64,
        "name": "Videos And Flash Movies and That Kind Of Crap",
        "viewing": 239
    }, {
        "id": 403,
        "name": "Mass Debate",
        "viewing": 9
    }, {
        "id": 396,
        "name": "Sensationalist Headlines",
        "viewing": 455
    }, {
        "id": 51,
        "name": "In The News Node",
        "viewing": 100
    }]
  }]
}

Part of my code

try {
    // Getting Array of Contacts
categories = json.getJSONArray(TAG_CATEGORIES);
forums = json.getJSONArray(TAG_FORUMS); 

// looping through All categories
for(int i = 0; i < categories.length(); i++){
    JSONObject c = categories.getJSONObject(i);


    // Storing each json item in variable
    String CatName = c.getString(TAG_CATName);

    // Phone number is agin JSON Object
            JSONObject All_forums = forums.getJSONObject(i);
            String forum_id = All_forums.getString(TAG_FORUMS_ID);
            String forum_name = All_forums.getString(TAG_FORUMS_NAME);

        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();

        // adding each child node to HashMap key => value
    map.put(TAG_CATName, CatName);
    map.put(TAG_FORUMS, forum_name);


    // adding HashList to ArrayList
    contactList.add(map);
}
} catch (JSONException e) {
    e.printStackTrace();
}
  • 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-19T01:17:36+00:00Added an answer on June 19, 2026 at 1:17 am

    To get the array of forums of one category you have to call

    forums = c.getJSONArray(TAG_FORUMS);
    

    inside your for-loop. Afterwards you can iterate over the forums to get their ids and names.

    Code sample:

    categories = json.getJSONArray(TAG_CATEGORIES);
    for(int i = 0; i < categories.length(); i++) {
        JSONObject c = categories.getJSONObject(i);
        forums = c.getJSONArray(TAG_FORUMS);
        for(int j = 0; j < forums.length(); j++){
            JSONObject f = forums.getJSONObject(j);
            String forum_id = f.getString(TAG_FORUMS_ID);
            String forum_name = f.getString(TAG_FORUMS_NAME);
            …
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can any one plz tell me where i am wrong.I want to get coordinates
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can a Visual Studio 2008 custom tool be passed additional parameters from the custom
Can anyone tell me what i am doing wrong? I am trying to get
Can I access my SkyDrive using a permanent access token? Basically, I want to
Can I prevent an .apk from being installed if unknown sources is checked?
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.