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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:41:04+00:00 2026-06-11T18:41:04+00:00

I have parsed a JSON file then saved a array from the JSON to

  • 0

I have parsed a JSON file then saved a array from the JSON to a string and passed that into the next activity to parse but I have a issue that the listview is only displaying the first set of locations and not any others.

JSON Snippet:

{
title: World Rover Scout Moot
locations: [
{
address: Kandersteg, Switzerland
latitude: 46.483742
longitude: 7.663157
name: 01st World Rover Moot (1921)
}
{
address: Ingarö, Sweden
latitude: 59.25235
longitude: 18.465536
name: 02nd World Rover Moot (1925)
}
{
address: Monzie, Scotland
latitude: 56.404182
longitude: -3.818855
name: 03rd World Rover Moot (1939)
}
{
address: Skjak, Norway
latitude: 61.898525
longitude: 8.369957
name: 04th World Rover Moot (1949)
}
{
address: Kandersteg, Switzerland
latitude: 46.483742
longitude: 7.663157
name: 05th World Rover Moot (1953)
}
{
address: Sutton Coldfield, UK
latitude: 52.558769
longitude: -1.802851
name: 06th World Rover Moot (1957)
}
{
address: Melbourne, Australia
latitude: -37.814251
longitude: 144.963165
name: 07th World Rover Moot (1961)
}
{
address: Melbourne, Australia
latitude: -37.814251
longitude: 144.963165
name: 08th World Rover Moot (1990-91)
}
{
address: Kandersteg, Switzerland
latitude: 46.483669
longitude: 7.663095
name: 09th World Rover Moot (1953)
}
{
address: Ransberg, Sweden
latitude: 58.454601
longitude: 14.226012
name: 10th World Moot (1996)
}
{ 
address: Mexico
latitude: 19.691061
longitude: -98.805557
name: 11th World Scout Moot (2000)
}
{
address: Hualien, Taiwan
latitude: 23.987925
longitude: 121.612175
name: 12th World Scout Moot (2004)
}
{
address: Nairobi, Kenya
latitude: -1.312558
longitude: 36.769932
name: 13th World Scout Moot
}
]
},

{
title: World Scout Interreligious Symposium
locations: [
{
address: Kampala, Uganda
latitude: 0.239059
longitude: 32.623615
name: 3rd World Scout Interreligious Symposium
}
]
}

Source Code:

public class SingleMapSet  extends Activity {
final String KEY_MAPS = "maps";

static final String KEY_MAPSETMAPSET = "";
static final String KEY_MAPNAME = "name";
static final String KEY_MAPLOCATION = "address";
static final String KEY_MAPLONG = "longitude";
static final String KEY_MAPLAT = "latitude";
ListView list;
org.scouts.android.maps.MapsetAdapter adapter;


/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.playlists);
    TextView lblTitle = (TextView) findViewById(R.id.actionbar);
    lblTitle.setText(R.string.maps);

    Intent in = getIntent();
    String mapset = in.getStringExtra(KEY_MAPSETMAPSET);
    mapset = mapset.substring(1);
    mapset = mapset.substring(0, mapset.length() - 1);



    final ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();


    String jsonString = null;
    try {
        jsonString = mapset;
    } catch (IllegalStateException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    JSONObject json = null;
    try {
        json = new JSONObject(jsonString);
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

           try{




               JSONArray  jsonArray = json.getJSONArray("locations");
               for(int i=0;i < jsonArray.length();i++){                     


            HashMap<String, String> map = new HashMap<String, String>();
            JSONObject maps = jsonArray.getJSONObject(i);

            map.put("id",  String.valueOf(i));
            map.put(KEY_MAPNAME, maps.getString(KEY_MAPNAME));
            map.put(KEY_MAPLOCATION, maps.getString(KEY_MAPLOCATION));
            map.put(KEY_MAPLONG, maps.getString("longitude"));
            map.put(KEY_MAPLAT, maps.getString("latitude"));

            mylist.add(map);


        }
           }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
           }
           list=(ListView)findViewById(R.id.playlistlist);          
           adapter=new org.scouts.android.maps.MapsetAdapter (this, mylist);        
           list.setAdapter(adapter);
           list.setOnItemClickListener(new OnItemClickListener() {

               public void onItemClick(AdapterView<?> parent, View view, int position,
                       long id) {

                   HashMap<String, String> map = mylist.get(position);

                   Intent in = new Intent(SingleMapSet.this, org.scouts.android.maps.SingleMapSet.class);
                   in.putExtra(KEY_MAPNAME, map.get(KEY_MAPNAME));
                   in.putExtra(KEY_MAPLOCATION, map.get(KEY_MAPLOCATION));
                   in.putExtra(KEY_MAPLONG, map.get(KEY_MAPLONG));
                   in.putExtra(KEY_MAPLAT, map.get(KEY_MAPLAT));

                startActivity(in);


            }
        });
    }








                };      ;
  • 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-11T18:41:05+00:00Added an answer on June 11, 2026 at 6:41 pm

    First remove this line
    mapset = mapset.substring(1);
    mapset = mapset.substring(0, mapset.length() – 1);

    and Try this way

     JSONObject jOBj;
     JSONArray  jsonArray;
     JSONArray jarray=new JSONArray(mapset);
    
     for(int j=0;j<jarray.length();j++){
           jOBj=jarray.getJSONObject(j)
           jsonArray = jOBj.getJSONArray("locations");
             for(int i=0;i < jsonArray.length();i++){                     
    
    
               HashMap<String, String> map = new HashMap<String, String>();
               JSONObject maps = jsonArray.getJSONObject(i);
    
               map.put("id",  String.valueOf(i));
               map.put(KEY_MAPNAME, maps.getString(KEY_MAPNAME));
               map.put(KEY_MAPLOCATION, maps.getString(KEY_MAPLOCATION));
               map.put(KEY_MAPLONG, maps.getString("longitude"));
               map.put(KEY_MAPLAT, maps.getString("latitude"));
    
               mylist.add(map);
    
    
        }
    
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jQuery won't parse my JSON from AJAX query So I have parsed
I have parse json file which contain more than hundred location name, there latitude
I have a JSON file and want to parse value of variable second value
I have a huge JSON file to parse in my Android app. I suppose
I have a flash file which loads data from JSON and parses it. It
Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
I have 2 activities. The first activity is an activity that parses JSON data
I have a JSON string called EmployeeList being passed back to my webpage. It
I have written a JSON parser that takes any valid json string and generates
I have made a custom ajax script to parse the JSON returned from the

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.