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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:57:06+00:00 2026-06-16T16:57:06+00:00

I am confused How to use looping for Json response Array in another Array.

  • 0

I am confused How to use looping for Json response Array in another Array. The following is my jsonresponse how to loop this to get data and images in listview

`{
"status": "ok", 

    "posts": [
        {
            "id": 2498,
            "title": "jigsaw lamp imported from thailand",
            "content": "<p>Hi. It&#8217;s a invitation to have a look at a unique lamp shade called jigsaw lamp from thailand. Available in multi attractive colours.</p>\n",
            "date": "2012-12-26 09:48:15",
             "author": {
                "name": "Tapas123456",
                            },
                "attachments": [
                {
                    "description": "",
                    "caption": "",
                    "mime_type": "image/jpeg",
                    "images": {
                    "thumbnail": {
                    "url": "http://site/wp-content/uploads/2012/12/646675-50x47.jpg",
                        }
                    }
                  ]
                },........

the following is the code i used to loop is this the right way of doing it?

    ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();


    // Creating JSON Parser instance
            JSONParser jParser = new JSONParser();

            // getting JSON string from URL
            JSONObject json = jParser.getJSONFromUrl(URL);
            try {
            posts = json.getJSONArray(KEY_POSTS);
    // looping through all song nodes <song>
            for(int i = 0; i < posts.length(); i++){
                JSONObject c = posts.getJSONObject(i);
                // Storing each json item in variable
                String id = c.getString(KEY_ID);
                String title = c.getString(KEY_TITLE);
                String date = c.getString(KEY_DATE);
                String content = c.getString(KEY_CONTENT);

                // Phone number is agin  JSON Object
                JSONObject author = c.getJSONObject(KEY_AUTHOR);
                String name = author.getString(KEY_NAME);

                JSONArray attachments = json.getJSONArray(KEY_ATTACHMENTS);

                for(int j = 0; j < attachments.length(); j++){
                    JSONObject d = attachments.getJSONObject(j);
                    JSONObject images = d.getJSONObject(KEY_IMAGES);

                    JSONObject thumbnail = d.getJSONObject(KEY_THUMB_URL);
                    String url = thumbnail.getString(KEY_URL);
                }
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();

        // adding each child node to HashMap key => value
        map.put(KEY_ID, id);
        map.put(KEY_TITLE, title);
        map.put(KEY_DATE, date);
        map.put(KEY_NAME, name);
        map.put(KEY_CONTENT, content);



        // adding HashList to ArrayList
        songsList.add(map);
  • 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-16T16:57:08+00:00Added an answer on June 16, 2026 at 4:57 pm

    Just Replace Following code

    for(int j = 0; j < attachments.length(); j++){
                        JSONObject d = attachments.getJSONObject(j);
                        JSONObject images = d.getJSONObject(KEY_IMAGES);
    
                        JSONObject thumbnail = images.getJSONObject(KEY_THUMB_URL);
                        String url = thumbnail.getString(KEY_URL);
                    }
    

    instead of old code.

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

Sidebar

Related Questions

I am confused why codeigniter wont let me use this: $(function() { var csrf
I always get confused when I am about to use a bit map to
I got a bit confused, because when I use the generic ListView class, Django
i am creating a big application (ERP system) and i am confused to use
I'm a bit confused about the use of all the IEnumerable<T> extension methods, intellisense
Today i was reading about pure function, got confused with its use: A function
I am a little confused about where to use strong and where to use
I am a bit confused on when to use CC_CONTENT_SCALE_FACTOR() in my app. I
I am quite confused with how to effectively use the Html.DropDownList helper for ASP.NET
I am confused as to how to use CSort in Yii for a drag

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.