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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:31:39+00:00 2026-06-05T04:31:39+00:00

{ transport : { public : [ { transport_id : 2, transport_name : Ferry

  • 0
{
   "transport" : {
   "public" : [
     {
    "transport_id" : "2",
    "transport_name" : "Ferry"
 },
 {
    "transport_id" : "3",
    "transport_name" : "Bus"
 },
 {
    "transport_id" : "4",
    "transport_name" : "Taxi"
 },
 {
    "transport_id" : "5",
    "transport_name" : "Tram"
 }
],
   "Private" : [
 {
    "transport_id" : "11",
    "transport_name" : "Bicycle"
 },
 {
    "transport_id" : "12",
    "transport_name" : "Private Car"
 }
],
  "Misc" : [
 {
    "transport_id" : "6",
    "transport_name" : "By Foot"
 },
 {
    "transport_id" : "7",
    "transport_name" : "Helicopter"
 },
 {
    "transport_id" : "8",
    "transport_name" : "Yatch"
 }
 ]
  }
}  

I was originally developing iOS app which extract the above JSON to a “ListView”, but now I am trying to do it in android, i was wondering how I can convert the above JSON to a sectioned List View.

Consider that the array “KEY” (i.e.:”public” , “private”…etc for the above example ) will be unknown and generate dynamically and so is the array quantity.

Thank you so much.

  • 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-05T04:31:41+00:00Added an answer on June 5, 2026 at 4:31 am

    You can Use built-in org.Json Package as following:

    String jsonString = "{
                        'transport' : {
                           'public' : [ ..."
    JSONObject jsonO = new JSONObject(jsonString);
    for (String key: jsonO.keys()){
        Object o = jsonO.get(key)
        if (o instanceof JSONArray){
            JSONArray jsonA = (JSONArray)o;
            int muberOfItems = jsonA.length();
            for(int i = 0; i<numberOfItems; i++){
                JSONObject jsonO2 = jsonA.optJSONObject(i)
                if (jsonO2 == null) // continue ? 
                //this object should contain your transportId and transportName
                String transportId = jsonO2.getString(0);
                String transportName = jsonO2.getString(1);
                //parse your Data, you have anything you need (private public etc == key)
                //whichValue = i
            }
        } else { //must be some other value }
    
    }
    

    JsonObjects contains other useful Methods, and can be considered as a HashMap like Object.

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

Sidebar

Related Questions

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.AndroidHttpTransport; import org.ksoap2.transport.HttpTransportSE; public class
I'm extend the WCF transport over a message bus, the request-reply mode works well
Are there any examples of database design for public transport time-tables ? Or any
Consider a Transport table with 3 fields: Engine Wheels Wings If Engine and Wheels
I've succeeded in getting WCF Transport security going for our Logon web service using
Error: Unable to read data from the transport connection: A blocking operation was interrupted
Our state government has opened its transport timetable data. The data is in xml
This article from Microsoft details how to implement transport security with an anonymous client
My program needs to make use of void* in order to transport data or
I'm trying to return a value from (transport) to the calling function, but can't

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.