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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:52:53+00:00 2026-06-11T02:52:53+00:00

http://docs.blackberry.com/sampledata.json This is my web service and I want to parse and retrieve vehicleType,

  • 0

http://docs.blackberry.com/sampledata.json

This is my web service and I want to parse and retrieve vehicleType, vehicleColor, fuel, name, experiencePoints, treadType.

public class MainActivity extends Activity {

    private static String url="http://maps.googleapis.com/maps/api/directions/json?origin=Tamil%20ndau,Salem&destination=Tamil%20nadu,%20salem&region=in&sensor=false";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        JSONObject json=JSONParser.getJSONfromURL(url);  // here i am able to read content of that web service 
    }
} catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        }

Please tell me how can I get the value? I’m not able to pick node for Json object and Json array. Please tell me what I have to do next so that I can retrieve the value. I am new in Json parsing and android. Please help me.

  • 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-11T02:52:55+00:00Added an answer on June 11, 2026 at 2:52 am

    May be this code help for you

    public class JSONfunctions {
    
    public static JSONArray getJSONfromURL(String url) {
        InputStream is = null;
        String result = "";
        JSONArray jArray = null;
    
        // http post
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
    
        } catch (Exception e) {
            Log.e("log_tag", "Error in http connection " + e.toString());
        }
    
        // convert response to string
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        } catch (Exception e) {
            Log.e("log_tag get data string ",
                    "Error converting result " + e.toString());
        }
    
        try {
    
            jArray = new JSONArray(result);
        } catch (JSONException e) {
            Log.e("log_tag create object ",
                    "Error parsing data " + e.toString());
        }
    
        return jArray;
    }
      }
    

    This is parsing code example you can change this.

    public class Main extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
    
        JSONArray json = JSONfunctions
                .getJSONfromURL("http://docs.blackberry.com/sampledata.json");
    
        for (int i = 0; i < json.length(); i++) {
    
            try {
                Log.e("json names vehicleType", ""
                        + json.getJSONObject(i).getString("vehicleType"));
                Log.e("json names vehicleColor", ""
                        + json.getJSONObject(i).getString("vehicleColor"));
                Log.e("json names fuel",
                        "" + json.getJSONObject(i).getString("fuel"));
                Log.e("json names treadType", ""
                        + json.getJSONObject(i).getString("treadType"));
    
                Log.e("json names approvedOperators",
                        ""
                                + json.getJSONObject(i).getJSONArray(
                                        "approvedOperators"));
    
                JSONArray array = json.getJSONObject(i).getJSONArray(
                        "approvedOperators");
                for (int j = 0; j < array.length(); j++) {
    
                    Log.e("json names approvedOperators name ", ""
                            + array.getJSONObject(j).getString("name"));
                    Log.e("json names approvedOperators experience ",
                            ""
                                    + array.getJSONObject(j).getString(
                                            "experiencePoints"));
    
                }
    
            } 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

So I want to use this plugin http://docs.jquery.com/Plugins/autocomplete I want to retrieve all the
This question is in reference to the API documentation link, http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/barcodelib/BarcodeBitmap.html They specify that
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
I've placed panel from this example http://docs.sencha.com/ext-js/4-0/#!/example/dd/dnd_grid_to_grid.html to Ext.window.Window and got an issue: proxy
I read this page http://docs.composite.net/XSLT/XSLTFAQ?q=How+to+parse+an+XHTML+value+from+a+data+field+used+in+XSLT+functions%3f but I can not make it to work with
Using JRE 5.0.0: import net.rim.device.api.util.StringProvider; http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/util/StringProvider.html What am I missing?
http://docs.djangoproject.com/en/dev/ref/models/fields/#choices i've read through the documentation and this implies using a database table for
The Django docs ( http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.post ) say to do this: >>> c = Client()
The documentation says: http://docs.djangoproject.com/en/dev/ref/settings/#time-zone Note that this is the time zone to which Django
In this presentation: http://docs.google.com/present/view?id=ddqht6x_1559tbtcgg Slide 6. The presenter's snippets_tags table has a primary key,

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.