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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:57:22+00:00 2026-05-29T05:57:22+00:00

Hi I’m working on a dynamic android application and i have the following json.

  • 0

Hi I’m working on a dynamic android application and i have the following json. Reading each line is fine i’ve figured out how to do this in java (keep in mind i just started working with json yesterday) how can i read the inner array of say sample item2 to an ArrayList in java i need some kind of loop to add to a string array the screen shot links. Thank you for any help with my problem.

 "Manager": 
[
    { 
"name" : "Sample item", 
"icon" : "http://www.test.com/icon.png", 
"link" : "http://www.test.com/sample.zip", 
"summary" : "sample summary here", 
"screenshots": [ 
    "http://test.com/link2screenshot1.png", 
    "http://test.com/link2screenshot2.png"
    ] 
    },
    { 
"name" : "Sample item2", 
"icon" : "http://www.test.com/icon2.png", 
"link" : "http://www.test.com/sample2.zip", 
"summary" : "sample summary here2", 
"screenshots": [ 
    "http://test.com/2/link2screenshot1.png", 
    "http://test.com/2/link2screenshot2.png"
    ] 
}
]

===EDIT===

Alright here is the final solution the following method will read a json from a url and pull what i want thanks to ninetwozero

public ArrayList<String> JSONInner(int count, String url, String outer, String inner){
    ArrayList<String> linkArrayList = new ArrayList<String>();
    URL u = null;
    StringBuilder FileData = null;
    try {
        u = new URL(url);
        String InputData =       null;
        InputStream is =         null;
        DataInputStream dis =    null;
        FileData = new StringBuilder();
        is = u.openStream();
        dis = new DataInputStream(new BufferedInputStream(is));
        while ((InputData = dis.readLine()) != null) {
            FileData.append(InputData);
        }
        is.close();
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    JSONObject json = null;
    try {
        json = new JSONObject(FileData.toString());
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    if(FileData.toString() != null) {
        try {
            JSONArray managerArray = json.getJSONArray(outer);
            JSONObject managerObject = managerArray.optJSONObject(count);
            JSONArray linkArray = managerObject.getJSONArray(inner);
            for(int subCount = 0, maxSubCount = linkArray.length(); subCount < maxSubCount; subCount++){
                linkArrayList.add( linkArray.getString( subCount ));
            }
        }catch (JSONException e){
            e.printStackTrace();
        }
    }
    return linkArrayList;
}
  • 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-29T05:57:22+00:00Added an answer on May 29, 2026 at 5:57 am

    I’d do it the following way:

    //Init
    ArrayList<String> linkArrayList = new ArrayList<String>();
    JSONArray managerArray = new JSONArray(yourString);
    
    //Iterate over the top-level array
    for( int count = 0, max = managerArray.length(); count < max; count++ ) {
    
        //Get the current JSONObject & the link array
        JSONObject managerObject = managerArray.optJSONObject(count);
        JSONArray linkArray = managerObject.getJSONArray("screenshots");
    
        //Iterate over the screenshots
        for( 
            int subCount = 0, maxSubCount = linkArray.length(); 
            subcount < maxSubCount; 
            subCount++ 
        ) {
    
            //Let's store the String
            linkArrayList.add( linkArray.getString( subCount );
    
        }
    
    }
    

    Let me know if this is what you’re looking for. 🙂

    Edit: However, this would give you ALL the links – if you just want the one for array item #2, then you can remove the outer loop and declare the following:

    int count = 0; //The 0 should be the index of your item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.