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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:48:27+00:00 2026-06-14T05:48:27+00:00

I want to get a JSON response on the simulator. How can I read

  • 0

I want to get a JSON response on the simulator. How can I read JSON from the server?

public void run()
{
      HttpConnection httpConn;
      ConnectionFactory connFact = new ConnectionFactory();
      ConnectionDescriptor connDesc;

      connDesc = connFact.getConnection("http://example.com/login.php");

      if (connDesc != null)
      {
          try {  
                  httpConn = (HttpConnection)connDesc.getConnection();
                  final int iResponseCode = httpConn.getResponseCode();

                  Dialog.alert("Type: "+httpConn.getType());

                  UiApplication.getUiApplication().invokeLater(new Runnable()
                  {
                      public void run()
                      {
                          Dialog.alert("Response code: " +  Integer.toString(iResponseCode)); 
                      }
                  });                         
           } 
           catch (IOException e) 
           {
                 System.err.println("Caught IOException: "  + e.getMessage());
           }
      }
}
  • 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-14T05:48:28+00:00Added an answer on June 14, 2026 at 5:48 am
    HttpConnection connection = (HttpConnection)Connector.open(urlConection);
    InputStream  inputStream = connection.openInputStream();
    if(connection.getResponseCode() == HttpConnection.HTTP_OK){
        InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8");
        int readCharacter;
        StringBuffer responseBuffer = new StringBuffer();
        while ((readCharacter = reader.read()) != -1) {
            responseBuffer.append((char) readCharacter);
            connection.close();
            inputStream.close();
            reader.close();
            String responseMessage = new String(responseBuffer);
        }
    }
    

    You need to create JSONObject for the response.

    try {
        JSONObject object = new JSONObject(responseMessage);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I load json-data from my server by using FMDB. The response I get (JSON),
I am currently using an InpuStream to get a JSON response from my server.
I have created a page where I want to get the JSON response from
I've WCF Service that response with JSON. I want to get the JSON String
Hi how to get json array elements in different ids in response? //server side
I use jquery ajax method, set datatype json, I get a jsonp response from
For a specific requirement in my project, I want to retrieve JSON response from
Suppose you're in your users controller and you want to get a json response
I'm trying serverside reverse geocoding that can get me a json response and now
I want to get json info from the link: http://android.forum-example.org/?a=1&b=2&c=3 but Log.v tells me

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.