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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:58:48+00:00 2026-06-02T06:58:48+00:00

i have an array from a json feed i know that in the jArray

  • 0

i have an array from a json feed i know that in the jArray there is one league but i need to work out the count of that array incase a second is added to the feed at a later date. at the moment log cat isn’t logging out “teamFeedStructure” does anyone know what I’m doing wrong or know how to correctly turn the length of an array into a string that i can use in an intent?

heres the code

JSONObject obj = new JSONObject(json);
JSONObject objData = obj.getJSONObject("data");                      
JSONArray jArray = objData.getJSONArray("structure");
//String leagues = jArray.toString();
//Log.v("myapp", "structure" + leagues);
for (int i=0; i < jArray.length(); i++) {    
     JSONObject oneObject = jArray.getJSONObject(i);
     leaguecountArray = oneObject.getJSONArray("league_id");
     for (int l=0; l < leaguecountArray.length(); l++) {     
         if (leaguecountArray.length() == 1) {
             teamFeedStructure = "One";
         }
         if (leaguecountArray.length() == 2) {
              teamFeedStructure = "Two";
         }
         Log.v("myapp", teamFeedStructure);  
      }
}
  • 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-02T06:58:49+00:00Added an answer on June 2, 2026 at 6:58 am

    Why do you need to iterate here:

    for (int l=0; l < leaguecountArray.length(); l++)
    {    
        if (leaguecountArray.length() == 1){
    
             teamFeedStructure = "One";
        }
        if (leaguecountArray.length() == 2){
    
            teamFeedStructure = "Two";
        }
        Log.v("myapp", teamFeedStructure);   
     }
    

    Nevermind how many passes you do the result will still be the same.

    Also you can use not English words, but String holding the number you need. Do like that:

    teamFeedStructure = String.valueOf(leaguecountArray.length());
    

    Then the value will become "2" for example. In your other activity you can parse it again to integer like that: int number = Integer.parseInt(teamFeedStructure);

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

Sidebar

Related Questions

I have a PHP file that serves up a JSON array populated from a
I have an array of dictionaries from a JSON feed. This populates a UITableView
I have an array of objects that I generate from JSON.parse. I access its
I have an array of 'tasks' that I am getting back from a JSON
I have an array that gets created from JSON. The array looks like this:
I have a function that retrieves some images from a JSON feed using NSURLConnection.
I have the following JSON content that I'm pulling from a service feed: [
Good day, I have a photo gallery that pulls from a json feed. The
how i can duplicate one element from array: for example, i have this array:
I have a byte array filled from a file uploaded. But, in another part

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.