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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:14:04+00:00 2026-06-04T16:14:04+00:00

I want to retrieve JSON from a web-service and parse it then. Am I

  • 0

I want to retrieve JSON from a web-service and parse it then.
Am I on the right way?

    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(url);
    HttpResponse response;
    try {
        response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        if (entity != null) {
           // parsing JSON
        }

    } catch (Exception e) {
    }

Unfortunately I don’t know how to convert HttpEntity into a JSONObject.

This is my JSON (extract):

{
    "names": [
        {
            "name": "Zachary"
        },
        {
            "name": "Wyatt"
        },
        {
            "name": "William"
        }
    ]
}
  • 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-04T16:14:06+00:00Added an answer on June 4, 2026 at 4:14 pm

    You can convert string to json as:

    try {
            response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();
    
            if (entity != null) {
               String retSrc = EntityUtils.toString(entity); 
               // parsing JSON
               JSONObject result = new JSONObject(retSrc); //Convert String to JSON Object
    
                 JSONArray tokenList = result.getJSONArray("names");
                 JSONObject oj = tokenList.getJSONObject(0);
                 String token = oj.getString("name"); 
            }
    }
     catch (Exception e) {
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that uses JavaScript to retrieve JSON from a web service.
I want to retrieve the data from this json url but is gives error.
I want to create JSON object using tow query in PHP , Then retrieve
I am new to jQuery and want to use it to retrieve data from
I manage to retrieve Json content from the URL: http://twitter.com/statuses/public_timeline.json Which provide just tweets.
I have this Bing Maps JSON file and I want to retrieve ++formattedAddress++ from
For a specific requirement in my project, I want to retrieve JSON response from
I'm building an app that retrieve JSON from URL. At first, I used emulator,
I am trying to retrieve values from a json api and displaying then in
As the title says, i want to retrieve my Json data values from a

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.