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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:34:26+00:00 2026-05-22T19:34:26+00:00

First thanks to Pentium10 for this answer ! it got me one step further.

  • 0

First thanks to Pentium10 for this answer! it got me one step further.

I have a JSONArray which is generated in php by

echo (json_encode($output));

which generates this output

// linebreaks only for readability, they do not exist in the response
[["Fitch's Chemist","731 Hay St","(08) 9321 6411"],
["Ferrara Karaoke Bar","67 Milligan Street","(08) 9481 1909"],
["Target: Perth","712-720 Hay St","(08) 9327 3700"],
["C Restaurant","44 St Georges Tce","(08) 9220 8333"],
["Celona Joe Tailors","146 Murray St","(08) 9325 8274"],
["Fashion In Colour","Shop 2, 138 Barrack St","(08) 9218 8233"],
["Mainpeak","858 Hay St","(08) 9322 9044"],
["Fj Storen Painting Contractors","34 Queen St","(08) 9486 9292"],
["Financial Pathfinders","Level 4\/81 St Georges Tce","(08) 9213 9699"],
["Seasons of Perth","37 Pier St","(08) 9325 7655"],
["David Jones","622 Hay St","(08) 9210 4000"],
["Pharmacity Chemist Supermart","717 Hay St","(08) 9322 6921"],
["Austcare","10 Pier St","(08) 9325 9330"],
["Western Australia","8 Pier St","(08) 9261 6222"],
["Oceanic Cruises","5 Barrack","(08) 9325 1191"]]

This outputs the list array filled as follows;

list(0)["Fitch's Chemist","731 Hay St","(08) 9321 6411"]
list(1)["Ferrara Karaoke Bar","67 Milligan Street","(08) 9481 1909"]

what I now need to do is extract this further so that the “” enclosed data is stored in three separate arrays

    try {
        JSONArray jsonArray = new JSONArray(response);
        List<String> list = new ArrayList<String>();
        for (int i=0; i<jsonArray.length(); i++) {
            list.add( jsonArray.getString(i) );
            JSONArray jsonList = new JSONArray(list);
            BusinessName.add(jsonList.getString(0));
            Address.add(jsonList.getString(1));
            TelNo.add(jsonList.getString(2));
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

Thanks Martin

  • 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-22T19:34:27+00:00Added an answer on May 22, 2026 at 7:34 pm

    edit: I tried your example and the code nearly works but has one little mistake. You shouldn’t use list to get the JSONArray jsonList.

    This works (tested):

    // this string is just used for testing, use your response...
    String json = "[[\"Fitch's Chemist\",\"731 Hay St\",\"(08) 9321 6411\"],"
                + "[\"Ferrara Karaoke Bar\",\"67 Milligan Street\",\"(08) 9481 1909\"],"
                + "[\"Target: Perth\",\"712-720 Hay St\",\"(08) 9327 3700\"],"
                + "[\"C Restaurant\",\"44 St Georges Tce\",\"(08) 9220 8333\"],"
                + "[\"Celona Joe Tailors\",\"146 Murray St\",\"(08) 9325 8274\"],"
                + "[\"Fashion In Colour\",\"Shop 2, 138 Barrack St\",\"(08) 9218 8233\"],"
                + "[\"Mainpeak\",\"858 Hay St\",\"(08) 9322 9044\"],"
                + "[\"Fj Storen Painting Contractors\",\"34 Queen St\",\"(08) 9486 9292\"],"
                + "[\"Financial Pathfinders\",\"Level 4/81 St Georges Tce\",\"(08) 9213 9699\"],"
                + "[\"Seasons of Perth\",\"37 Pier St\",\"(08) 9325 7655\"],"
                + "[\"David Jones\",\"622 Hay St\",\"(08) 9210 4000\"],"
                + "[\"Pharmacity Chemist Supermart\",\"717 Hay St\",\"(08) 9322 6921\"],"
                + "[\"Austcare\",\"10 Pier St\",\"(08) 9325 9330\"],"
                + "[\"Western Australia\",\"8 Pier St\",\"(08) 9261 6222\"],"
                + "[\"Oceanic Cruises\",\"5 Barrack\",\"(08) 9325 1191\"]]";
    
    try {
        JSONArray jsonArray = new JSONArray(json);
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < jsonArray.length(); i++) {
            list.add(jsonArray.getString(i));
            // thats the correct line:
            JSONArray jsonList = new JSONArray(jsonArray.getString(i));
            // Used for debug/test, use your own objects BusinessName, Address and TelNo
            System.out.println(jsonList.getString(0) + ":" + jsonList.getString(1) + ":" + jsonList.getString(2));
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First hi and thanks in advance in ASP.NET : assume that i have a
First of all thanks in advance, this has been very frustrating and I'm hoping
First of all many thanks for clicking into my question. I have a few
This is my first question. Thanks to everyone who contributes to this site, it's
and first off thanks for your time to look at this. For a research
Okay look first thanks for this place :) I would like to create a
First off thanks for any help provided. I have an array/loop issue. I'm trying
First I want to say thanks to everyone that reads this. Stackoverflow is an
First thanks for reading me and sorry for my bad english. I have the
First off thanks to all the users who have made my android developing adventure

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.